Skip to content

Commit c98c758

Browse files
Copilothuangyiirene
andcommitted
Add Fumadocs documentation site setup
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent 916b305 commit c98c758

16 files changed

Lines changed: 412 additions & 527 deletions

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,11 @@ temp/
4141
packages/*/dist/
4242
packages/*/*.tsbuildinfo
4343

44-
.next
44+
# Next.js
45+
.next
46+
out/
47+
next-env.d.ts
48+
.vercel
49+
50+
# Fumadocs
51+
.source/

app/docs/[[...slug]]/page.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { source } from '@/app/source';
2+
import type { Metadata } from 'next';
3+
import { DocsPage, DocsBody } from 'fumadocs-ui/page';
4+
import { notFound } from 'next/navigation';
5+
6+
export default async function Page(props: {
7+
params: Promise<{ slug?: string[] }>;
8+
}) {
9+
const params = await props.params;
10+
const page = await source.getPage(params.slug ?? []);
11+
if (!page) notFound();
12+
13+
const Content = (page.data as any).body;
14+
15+
return (
16+
<DocsPage>
17+
<DocsBody>
18+
<h1>{page.data.title}</h1>
19+
{page.data.description && <p>{page.data.description}</p>}
20+
<Content />
21+
</DocsBody>
22+
</DocsPage>
23+
);
24+
}
25+
26+
export async function generateStaticParams() {
27+
return source.generateParams();
28+
}
29+
30+
export async function generateMetadata(props: {
31+
params: Promise<{ slug?: string[] }>;
32+
}): Promise<Metadata> {
33+
const params = await props.params;
34+
const page = await source.getPage(params.slug ?? []);
35+
if (!page) notFound();
36+
37+
return {
38+
title: page.data.title,
39+
description: page.data.description,
40+
};
41+
}

app/docs/layout.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { source } from '@/app/source';
2+
import type { Metadata } from 'next';
3+
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
4+
import type { ReactNode } from 'react';
5+
import { baseOptions } from '@/app/layout.config';
6+
7+
export default function Layout({ children }: { children: ReactNode }) {
8+
return (
9+
<DocsLayout tree={source.pageTree} {...baseOptions}>
10+
{children}
11+
</DocsLayout>
12+
);
13+
}
14+
15+
export function generateMetadata(): Metadata {
16+
return {
17+
title: {
18+
default: 'ObjectStack Protocol',
19+
template: '%s | ObjectStack Protocol',
20+
},
21+
description: 'The Standard for Post-SaaS Operating Systems',
22+
};
23+
}

app/global.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import "tailwindcss";
2+
@import "fumadocs-ui/style.css";

app/layout.config.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
2+
3+
export const baseOptions: BaseLayoutProps = {
4+
nav: {
5+
title: 'ObjectStack Protocol',
6+
transparentMode: 'top',
7+
},
8+
links: [
9+
{
10+
text: 'Documentation',
11+
url: '/docs',
12+
active: 'nested-url',
13+
},
14+
],
15+
githubUrl: 'https://github.com/objectstack-ai/spec',
16+
};

app/layout.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import './global.css';
2+
import { RootProvider } from 'fumadocs-ui/provider/next';
3+
import type { ReactNode } from 'react';
4+
5+
export default function Layout({ children }: { children: ReactNode }) {
6+
return (
7+
<html lang="en" suppressHydrationWarning>
8+
<body>
9+
<RootProvider>{children}</RootProvider>
10+
</body>
11+
</html>
12+
);
13+
}

app/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { redirect } from 'next/navigation';
2+
3+
export default function HomePage() {
4+
redirect('/docs');
5+
}

app/source.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { docs, meta } from '@/.source/server';
2+
import { loader } from 'fumadocs-core/source';
3+
4+
export const source = loader({
5+
baseUrl: '/docs',
6+
source: {
7+
files: docs.map((doc: any) => ({
8+
type: 'page' as const,
9+
path: doc.path,
10+
data: doc,
11+
})),
12+
} as any,
13+
});

next.config.mjs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { createMDX } from 'fumadocs-mdx/next';
2+
3+
const withMDX = createMDX();
4+
5+
/** @type {import('next').NextConfig} */
6+
const config = {
7+
reactStrictMode: true,
8+
output: 'standalone',
9+
typescript: {
10+
ignoreBuildErrors: false,
11+
},
12+
};
13+
14+
export default withMDX(config);

package.json

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"clean": "pnpm -r --parallel clean && rm -rf dist",
1010
"version": "changeset version",
1111
"release": "pnpm run build && changeset publish",
12-
"docs:dev": "objectdocs dev",
13-
"docs:build": "objectdocs build",
14-
"docs:start": "objectdocs start"
12+
"docs:dev": "next dev",
13+
"docs:build": "next build",
14+
"docs:start": "next start"
1515
},
1616
"keywords": [
1717
"objectstack",
@@ -24,18 +24,30 @@
2424
"license": "Apache-2.0",
2525
"devDependencies": {
2626
"@changesets/cli": "^2.27.1",
27+
"@tailwindcss/postcss": "^4.1.18",
28+
"@tailwindcss/typography": "^0.5.19",
2729
"@types/node": "^20.10.0",
28-
"typescript": "^5.3.0"
30+
"@types/react": "^19.2.8",
31+
"@types/react-dom": "^19.2.3",
32+
"autoprefixer": "^10.4.23",
33+
"fumadocs-core": "^16.4.7",
34+
"fumadocs-mdx": "^14.2.5",
35+
"fumadocs-ui": "^16.4.7",
36+
"postcss": "^8.5.6",
37+
"tailwindcss": "^4.0.0",
38+
"typescript": "^5.3.0",
39+
"zod": "4.3.5"
2940
},
3041
"engines": {
3142
"node": ">=18.0.0"
3243
},
3344
"packageManager": "pnpm@10.28.0",
3445
"dependencies": {
35-
"@objectdocs/cli": "^0.2.11",
3646
"client-only": "^0.0.1",
3747
"lucide-react": "^0.562.0",
3848
"next": "^16.1.3",
49+
"react": "^19.2.3",
50+
"react-dom": "^19.2.3",
3951
"server-only": "^0.0.1"
4052
}
4153
}

0 commit comments

Comments
 (0)