Skip to content

Commit

Permalink
feat(docs): going public (#784)
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Croft <[email protected]>
Co-authored-by: gautamgambhir97 <[email protected]>
Co-authored-by: gautamgambhir97 <[email protected]>
  • Loading branch information
4 people authored Jul 15, 2024
1 parent 603dfee commit e94347c
Show file tree
Hide file tree
Showing 42 changed files with 95 additions and 2,006 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
BACKEND_URL=
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID=
NEXT_PUBLIC_ALGOLIA_APP_ID=
NEXT_PUBLIC_ALGOLIA_API_KEY=
NEXT_PUBLIC_ALGOLIA_INDEX=
NEWSLETTER_BASE_URL=
2 changes: 0 additions & 2 deletions .env.local

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
env:
BACKEND_URL: ${{ secrets.NEXT_PUBLIC_BACKEND_URL }}
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID }}
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}
NEXT_PUBLIC_ALGOLIA_API_KEY: ${{ secrets.NEXT_PUBLIC_ALGOLIA_API_KEY }}
NEXT_PUBLIC_ALGOLIA_INDEX: ${{ secrets.NEXT_PUBLIC_ALGOLIA_INDEX }}
NEWSLETTER_BASE_URL: ${{ secrets.NEWSLETTER_BASE_URL }}
SENDER_TOKEN: ${{ secrets.SENDER_TOKEN }}

- name: Trigger Image Update
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ jobs:
env:
BACKEND_URL: ${{ secrets.STAGING_NEXT_PUBLIC_BACKEND_URL }}
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID }}
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}
NEXT_PUBLIC_ALGOLIA_API_KEY: ${{ secrets.NEXT_PUBLIC_ALGOLIA_API_KEY }}
NEXT_PUBLIC_ALGOLIA_INDEX: ${{ secrets.NEXT_PUBLIC_ALGOLIA_INDEX }}
NEWSLETTER_BASE_URL: ${{ secrets.NEWSLETTER_BASE_URL }}
SENDER_TOKEN: ${{ secrets.SENDER_TOKEN }}

deploy:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ephemeral-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
env:
BACKEND_URL: ${{ secrets.STAGING_NEXT_PUBLIC_BACKEND_URL }}
NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID: ${{ secrets.NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID }}
NEXT_PUBLIC_ALGOLIA_APP_ID: ${{ secrets.NEXT_PUBLIC_ALGOLIA_APP_ID }}
NEXT_PUBLIC_ALGOLIA_API_KEY: ${{ secrets.NEXT_PUBLIC_ALGOLIA_API_KEY }}
NEXT_PUBLIC_ALGOLIA_INDEX: ${{ secrets.NEXT_PUBLIC_ALGOLIA_INDEX }}
NEWSLETTER_BASE_URL: ${{ secrets.NEWSLETTER_BASE_URL }}
SENDER_TOKEN: ${{ secrets.SENDER_TOKEN }}

deploy:
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
FROM node:18-alpine

ARG BACKEND_URL=""
ARG NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID=""
ARG NEXT_PUBLIC_ALGOLIA_APP_ID=""
ARG NEXT_PUBLIC_ALGOLIA_API_KEY=""
ARG NEXT_PUBLIC_ALGOLIA_INDEX=""
ARG NEWSLETTER_BASE_URL=""
ARG SENDER_TOKEN=""

RUN apk add tree && corepack prepare [email protected] --activate && corepack enable
Expand All @@ -17,6 +22,10 @@ ENV NODE_ENV="production"
RUN echo BACKEND_URL="${BACKEND_URL}" > .env.local && \
echo SENDER_TOKEN="${SENDER_TOKEN}" > .env.local && \
echo NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID="${NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID}" >> .env.local && \
echo NEXT_PUBLIC_ALGOLIA_APP_ID="${NEXT_PUBLIC_ALGOLIA_APP_ID}" >> .env.local && \
echo NEXT_PUBLIC_ALGOLIA_API_KEY="${NEXT_PUBLIC_ALGOLIA_API_KEY}" >> .env.local && \
echo NEXT_PUBLIC_ALGOLIA_INDEX="${NEXT_PUBLIC_ALGOLIA_INDEX}" >> .env.local && \
echo NEWSLETTER_BASE_URL="${NEWSLETTER_BASE_URL}" >> .env.local && \
pnpm build

ENTRYPOINT ["pnpm"]
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ Select the appropriate route, and create a new file ending in `.mdx`. Then, upda
}
```

## Deployments

### Staging Website

https://docs-staging.sandbox-london-b.fetch-ai.com/docs

## Developing

### Install dependencies
Expand Down
80 changes: 0 additions & 80 deletions components/account-menu.tsx

This file was deleted.

32 changes: 14 additions & 18 deletions components/api-endpoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import {
Tab,
DropDownTabs,
} from "./mdx";
import { useUserContext } from "theme/fetch-ai-docs/contexts/context-provider";
import Tooltip from "./tooltip";
import Link from "next/link";
import fetchJson from "src/lib/fetch-json";

interface PropertyType {
name: string;
Expand Down Expand Up @@ -347,29 +345,27 @@ export const ApiEndpointRequestResponse: React.FC<{
setIsModalOpen(false);
};

const context = useUserContext();

const hitRequest = async () => {
const hitRequestWithoutLogin = async () => {
try {
setLoading(true);
setError("");
const requestPayloadJSON = JSON.parse(requestPayload || "{}");
const apiUrlWithParams = (properties.apiUrl +
replacePathParameters(properties.path, pathParameters)) as string;

const response: { data: unknown } = await fetchJson(
`/docs/api/api-requests?url=${apiUrlWithParams}`,
{
method: properties.method,
body: properties.method.includes("GET") ? null : requestPayloadJSON,
const response = await fetch(apiUrlWithParams, {
method: properties.method,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${bearerToken}`,
},
);
const responseText = JSON.stringify(response.data, null, 2);
body: properties.method.includes("GET")
? null
: JSON.stringify(requestPayloadJSON),
});
const data = await response.json();
const responseText = JSON.stringify(data, null, 2);
setActualResponse(responseText);
} catch (error) {
if (error.response.status === 422) {
context.signOut();
}
setError(`Error: ${error.message}`);
} finally {
setLoading(false);
Expand Down Expand Up @@ -420,7 +416,7 @@ export const ApiEndpointRequestResponse: React.FC<{
</div>
</div>
<div className="nx-mt-2 nx-mb-4 nx-border-t nx-border-gray-300" />
{!context?.isLoggedIn && isBearerTokenRequired && (
{isBearerTokenRequired && (
<div className="md:nx-flex nx-block nx-items-center nx-ml-4">
<div className="nx-flex nx-gap-2 nx-w-1/4">
<p className="nextra-content nx-text-sm">
Expand Down Expand Up @@ -530,7 +526,7 @@ export const ApiEndpointRequestResponse: React.FC<{
<div className="nx-w-1/4">
<button
className="nx-bg-purple hover:nx-bg-purple-500 nx-text-white nx-py-2 nx-px-4 nx-rounded-xxl nx-text-sm nx-mt-6"
onClick={hitRequest}
onClick={hitRequestWithoutLogin}
>
Execute
</button>
Expand Down
2 changes: 1 addition & 1 deletion components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const Footer: React.FC = () => {
<div className={styles.footerInputWrapper}>
<div className={styles.footerInput}>
<span className={styles.footerText}>
Sign up to for developer updates
Sign up for developer updates
</span>
<div className={styles.inputBox}>
<input
Expand Down
7 changes: 5 additions & 2 deletions index-data-to-algolia.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import path from "node:path";
import matter from "gray-matter";
import striptags from "striptags";

const client = algoliasearch("J27DIPDG4S", "");
const index = client.initIndex("12-6-24-index");
const client = algoliasearch(
`${process.env.NEXT_PUBLIC_ALGOLIA_APP_ID}`,
`${process.env.NEXT_PUBLIC_ALGOLIA_API_KEY}`,
);
const index = client.initIndex(`${process.env.NEXT_PUBLIC_ALGOLIA_INDEX}`);

const docsPath = path.join(process.cwd(), "pages");

Expand Down
6 changes: 5 additions & 1 deletion k8s/build-img.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@
BUILD_ENV_VARS = (
'BACKEND_URL',
'NEXT_PUBLIC_GOOGLE_ANALYTICS_TRACKING_ID',
'SENDER_TOKEN',
'NEXT_PUBLIC_ALGOLIA_APP_ID',
'NEXT_PUBLIC_ALGOLIA_API_KEY',
'NEXT_PUBLIC_ALGOLIA_INDEX',
'NEWSLETTER_BASE_URL',
'SENDER_TOKEN'
)

def _profile(text: str) -> str:
Expand Down
101 changes: 0 additions & 101 deletions pages/api/api-requests.ts

This file was deleted.

Loading

0 comments on commit e94347c

Please sign in to comment.