Skip to content

Commit 7507e96

Browse files
rajat1saxenaRajat
andauthored
OpenAPI documentation + Fumadocs based documentation site (#764)
* OpenAPI spec + Fumadocs based documentation site * prettier fixes * build fixes * Orama integration * build fix * prettier fix * Updated lock file * Replaced hardcoded values with secrets * codex fix * Added posthog analytics and banner on the old site to point to new site * lint and prettier checks for docs-new * GH action fixes * more fix * even more fix * Fixed Api reference * lint fix * Fixed school url and header in openapi docs and new doc site * Added .mjs and .json to lint-staged * Removed irrevelant developer docs * Removed vercel from self hosting * Refined a doc * regression fix: broken sequence triggering logic * Removed unused vars * Removed used var --------- Co-authored-by: Rajat <hi@rajatsaxena.dev>
1 parent 7d3a405 commit 7507e96

437 files changed

Lines changed: 11465 additions & 672 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/code-quality.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ jobs:
1010
lint:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v1
13+
- uses: actions/checkout@v4
14+
- uses: pnpm/action-setup@v4
15+
- uses: actions/setup-node@v4
1516
with:
16-
node-version: '24.x'
17-
- uses: pnpm/action-setup@v2
18-
with:
19-
version: 8
20-
- run: pnpm install
17+
node-version: "24"
18+
cache: pnpm
19+
- run: pnpm install --frozen-lockfile
2120
- name: Linting and prettifying
2221
run: |
2322
pnpm lint
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Deploy new documentation to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
paths:
7+
- "apps/docs-new/**"
8+
- "apps/web/openapi/**"
9+
- ".github/workflows/deploy-docs-new-to-pages.yml"
10+
- "pnpm-lock.yaml"
11+
- "pnpm-workspace.yaml"
12+
- "package.json"
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
concurrency:
21+
group: "pages-docs-new"
22+
cancel-in-progress: false
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Node
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: "20"
35+
36+
- name: Setup pnpm
37+
uses: pnpm/action-setup@v4
38+
39+
- name: Setup Pages
40+
id: pages
41+
uses: actions/configure-pages@v5
42+
43+
- name: Install dependencies
44+
run: pnpm install --frozen-lockfile
45+
46+
- name: Generate OpenAPI spec
47+
run: pnpm --filter @courselit/web openapi:generate
48+
49+
- name: Build docs site
50+
env:
51+
NEXT_PUBLIC_BASE_PATH: ${{ steps.pages.outputs.base_path }}
52+
POSTHOG_KEY: ${{ secrets.POSTHOG_KEY }}
53+
NEXT_PUBLIC_ORAMA_PROJECT_ID: ${{ secrets.ORAMA_PROJECT_ID }}
54+
NEXT_PUBLIC_ORAMA_API_KEY: ${{ secrets.ORAMA_API_KEY }}
55+
run: pnpm --filter @courselit/docs-new build
56+
57+
- name: Sync Orama search index
58+
env:
59+
NEXT_PUBLIC_ORAMA_DATASOURCE_ID: ${{ secrets.ORAMA_DATASOURCE_ID }}
60+
NEXT_PUBLIC_ORAMA_PROJECT_ID: ${{ secrets.ORAMA_PROJECT_ID }}
61+
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
62+
run: pnpm --filter @courselit/docs-new search:sync
63+
64+
- name: Upload artifact
65+
uses: actions/upload-pages-artifact@v3
66+
with:
67+
path: ./apps/docs-new/out
68+
69+
deploy:
70+
environment:
71+
name: github-pages
72+
url: ${{ steps.deployment.outputs.page_url }}
73+
runs-on: ubuntu-latest
74+
needs: build
75+
steps:
76+
- name: Deploy to GitHub Pages
77+
id: deployment
78+
uses: actions/deploy-pages@v4

.github/workflows/publish-packages.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
registry-url: https://registry.npmjs.org
5050

5151
- name: Install Packages
52-
run: pnpm install
52+
run: pnpm install --frozen-lockfile
5353

5454
- name: Create and publish versions
5555
id: changesets

.github/workflows/test.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v1
13+
- uses: actions/checkout@v4
14+
- uses: pnpm/action-setup@v4
15+
- uses: actions/setup-node@v4
1516
with:
16-
node-version: '23.x'
17-
- uses: pnpm/action-setup@v2
18-
with:
19-
version: 10
20-
- run: pnpm install
17+
node-version: "24"
18+
cache: pnpm
19+
- run: pnpm install --frozen-lockfile
2120
- name: Build packages
2221
run: |
2322
pnpm --filter @courselit/icons build

.prettierignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
.next/
33

44
# Ignore build files
5-
dist/
5+
dist/
6+
**/dist/
7+
out/_next/
8+
**/out/
9+
**/out/_next/

apps/docs-new/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
NEXT_PUBLIC_BASE_PATH=/
2+
NEXT_PUBLIC_ORAMA_DATASOURCE_ID=default
3+
NEXT_PUBLIC_ORAMA_PROJECT_ID=default
4+
NEXT_PUBLIC_ORAMA_API_KEY=default

apps/docs-new/.eslintrc.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
ignorePatterns: [".next/**", "out/**", "dist/**", ".source/**"],
3+
};

apps/docs-new/.gitignore

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env.local
30+
.env.development.local
31+
.env.test.local
32+
.env.production.local
33+
34+
# vercel
35+
.vercel
36+
37+
# typescript
38+
*.tsbuildinfo
39+
40+
# analyze
41+
/analyze
42+
43+
# generated content
44+
/.source/
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import { source } from "@/lib/source";
2+
import {
3+
DocsBody,
4+
DocsDescription,
5+
DocsPage,
6+
DocsTitle,
7+
} from "fumadocs-ui/page";
8+
import { createRelativeLink } from "fumadocs-ui/mdx";
9+
import { notFound, redirect } from "next/navigation";
10+
import { APIPage } from "@/components/api-page";
11+
import { getMDXComponents } from "@/mdx-components";
12+
13+
const API_REFERENCE_INDEX = "/api-reference/createUser";
14+
15+
export default async function Page(props: {
16+
params: Promise<{ slug?: string[] }>;
17+
}) {
18+
const params = await props.params;
19+
const slugPath = params.slug?.join("/");
20+
21+
if (slugPath === "api-reference" || slugPath === "rest-api") {
22+
redirect(API_REFERENCE_INDEX);
23+
}
24+
25+
const page = source.getPage(params.slug);
26+
if (!page) notFound();
27+
28+
if (page.data.type === "openapi") {
29+
return (
30+
<DocsPage full>
31+
<DocsTitle>{page.data.title}</DocsTitle>
32+
<DocsDescription>{page.data.description}</DocsDescription>
33+
<DocsBody>
34+
<APIPage {...page.data.getAPIPageProps()} />
35+
</DocsBody>
36+
</DocsPage>
37+
);
38+
}
39+
40+
const MDXContent = page.data.body;
41+
42+
return (
43+
<DocsPage toc={page.data.toc} full={page.data.full}>
44+
<DocsTitle>{page.data.title}</DocsTitle>
45+
<DocsDescription>{page.data.description}</DocsDescription>
46+
<DocsBody>
47+
<MDXContent
48+
components={getMDXComponents({
49+
a: createRelativeLink(source, page),
50+
})}
51+
/>
52+
</DocsBody>
53+
</DocsPage>
54+
);
55+
}
56+
57+
export async function generateStaticParams() {
58+
const params = source.generateParams();
59+
const bySlug = new Map<string, { slug?: string[] }>();
60+
61+
for (const param of [
62+
{ slug: [] as string[] },
63+
...params,
64+
{ slug: ["api-reference"] },
65+
{ slug: ["rest-api"] },
66+
]) {
67+
bySlug.set((param.slug ?? []).join("/"), param);
68+
}
69+
70+
return [...bySlug.values()];
71+
}
72+
73+
export async function generateMetadata(props: {
74+
params: Promise<{ slug?: string[] }>;
75+
}) {
76+
const params = await props.params;
77+
78+
if (params.slug?.join("/") === "api-reference") {
79+
return {
80+
title: "API Reference",
81+
description: "Interactive REST API documentation for CourseLit.",
82+
};
83+
}
84+
85+
const page = source.getPage(params.slug);
86+
if (!page) notFound();
87+
88+
return {
89+
title: page.data.title,
90+
description: page.data.description,
91+
};
92+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { DocsLayout } from "fumadocs-ui/layouts/docs";
2+
import type { Root } from "fumadocs-core/page-tree";
3+
import type { ReactNode } from "react";
4+
import { baseOptions } from "@/app/layout.config";
5+
import { source } from "@/lib/source";
6+
7+
export default function Layout({ children }: { children: ReactNode }) {
8+
return (
9+
<DocsLayout tree={source.pageTree as unknown as Root} {...baseOptions}>
10+
{children}
11+
</DocsLayout>
12+
);
13+
}

0 commit comments

Comments
 (0)