Initialize documentation module with Fumadocs integration and basic setup
This commit is contained in:
26
documentation/.gitignore
vendored
Normal file
26
documentation/.gitignore
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# deps
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# generated content
|
||||||
|
.source
|
||||||
|
|
||||||
|
# test & build
|
||||||
|
/coverage
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
/build
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# others
|
||||||
|
.env*.local
|
||||||
|
.vercel
|
||||||
|
next-env.d.ts
|
||||||
45
documentation/README.md
Normal file
45
documentation/README.md
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# documentation
|
||||||
|
|
||||||
|
This is a Next.js application generated with
|
||||||
|
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).
|
||||||
|
|
||||||
|
Run development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
# or
|
||||||
|
pnpm dev
|
||||||
|
# or
|
||||||
|
yarn dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Open http://localhost:3000 with your browser to see the result.
|
||||||
|
|
||||||
|
## Explore
|
||||||
|
|
||||||
|
In the project, you can see:
|
||||||
|
|
||||||
|
- `lib/source.ts`: Code for content source adapter, [`loader()`](https://fumadocs.dev/docs/headless/source-api) provides the interface to access your content.
|
||||||
|
- `lib/layout.shared.tsx`: Shared options for layouts, optional but preferred to keep.
|
||||||
|
|
||||||
|
| Route | Description |
|
||||||
|
| ------------------------- | ------------------------------------------------------ |
|
||||||
|
| `app/(home)` | The route group for your landing page and other pages. |
|
||||||
|
| `app/docs` | The documentation layout and pages. |
|
||||||
|
| `app/api/search/route.ts` | The Route Handler for search. |
|
||||||
|
|
||||||
|
### Fumadocs MDX
|
||||||
|
|
||||||
|
A `source.config.ts` config file has been included, you can customise different options like frontmatter schema.
|
||||||
|
|
||||||
|
Read the [Introduction](https://fumadocs.dev/docs/mdx) for further details.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
To learn more about Next.js and Fumadocs, take a look at the following
|
||||||
|
resources:
|
||||||
|
|
||||||
|
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
|
||||||
|
features and API.
|
||||||
|
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||||
|
- [Fumadocs](https://fumadocs.dev) - learn about Fumadocs
|
||||||
41
documentation/biome.json
Normal file
41
documentation/biome.json
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://biomejs.dev/schemas/2.3.11/schema.json",
|
||||||
|
"vcs": {
|
||||||
|
"enabled": true,
|
||||||
|
"clientKind": "git",
|
||||||
|
"useIgnoreFile": true
|
||||||
|
},
|
||||||
|
"files": {
|
||||||
|
"ignoreUnknown": true,
|
||||||
|
"includes": [
|
||||||
|
"**",
|
||||||
|
"!node_modules",
|
||||||
|
"!.next",
|
||||||
|
"!dist",
|
||||||
|
"!build",
|
||||||
|
"!.source"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"formatter": {
|
||||||
|
"enabled": true,
|
||||||
|
"indentStyle": "tab",
|
||||||
|
"indentWidth": 1
|
||||||
|
},
|
||||||
|
"linter": {
|
||||||
|
"enabled": true,
|
||||||
|
"rules": {
|
||||||
|
"recommended": true
|
||||||
|
},
|
||||||
|
"domains": {
|
||||||
|
"next": "recommended",
|
||||||
|
"react": "recommended"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"assist": {
|
||||||
|
"actions": {
|
||||||
|
"source": {
|
||||||
|
"organizeImports": "on"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
documentation/content/docs/index.mdx
Normal file
13
documentation/content/docs/index.mdx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title: Hello World
|
||||||
|
description: Your first document
|
||||||
|
---
|
||||||
|
|
||||||
|
Welcome to the docs! You can start writing documents in `/content/docs`.
|
||||||
|
|
||||||
|
## What is Next?
|
||||||
|
|
||||||
|
<Cards>
|
||||||
|
<Card title="Learn more about Next.js" href="https://nextjs.org/docs" />
|
||||||
|
<Card title="Learn more about Fumadocs" href="https://fumadocs.dev" />
|
||||||
|
</Cards>
|
||||||
17
documentation/content/docs/test.mdx
Normal file
17
documentation/content/docs/test.mdx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: Components
|
||||||
|
description: Components
|
||||||
|
---
|
||||||
|
|
||||||
|
## Code Block
|
||||||
|
|
||||||
|
```js
|
||||||
|
console.log('Hello World');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cards
|
||||||
|
|
||||||
|
<Cards>
|
||||||
|
<Card title="Learn more about Next.js" href="https://nextjs.org/docs" />
|
||||||
|
<Card title="Learn more about Fumadocs" href="https://fumadocs.dev" />
|
||||||
|
</Cards>
|
||||||
10
documentation/next.config.mjs
Normal file
10
documentation/next.config.mjs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { createMDX } from 'fumadocs-mdx/next';
|
||||||
|
|
||||||
|
const withMDX = createMDX();
|
||||||
|
|
||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
const config = {
|
||||||
|
reactStrictMode: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default withMDX(config);
|
||||||
34
documentation/package.json
Normal file
34
documentation/package.json
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"name": "@memegoat/documentation",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"build": "next build",
|
||||||
|
"dev": "next dev",
|
||||||
|
"start": "next start",
|
||||||
|
"types:check": "fumadocs-mdx && next typegen && tsc --noEmit",
|
||||||
|
"postinstall": "fumadocs-mdx",
|
||||||
|
"lint": "biome check",
|
||||||
|
"format": "biome format --write"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"fumadocs-core": "16.4.3",
|
||||||
|
"fumadocs-mdx": "14.2.4",
|
||||||
|
"fumadocs-ui": "16.4.3",
|
||||||
|
"lucide-react": "^0.562.0",
|
||||||
|
"next": "16.1.1",
|
||||||
|
"react": "^19.2.3",
|
||||||
|
"react-dom": "^19.2.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/postcss": "^4.1.18",
|
||||||
|
"@types/mdx": "^2.0.13",
|
||||||
|
"@types/node": "^24.10.2",
|
||||||
|
"@types/react": "^19.2.7",
|
||||||
|
"@types/react-dom": "^19.2.3",
|
||||||
|
"postcss": "^8.5.6",
|
||||||
|
"tailwindcss": "^4.1.18",
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"@biomejs/biome": "^2.3.10"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
documentation/postcss.config.mjs
Normal file
5
documentation/postcss.config.mjs
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
'@tailwindcss/postcss': {},
|
||||||
|
},
|
||||||
|
};
|
||||||
22
documentation/source.config.ts
Normal file
22
documentation/source.config.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { defineConfig, defineDocs, frontmatterSchema, metaSchema } from 'fumadocs-mdx/config';
|
||||||
|
|
||||||
|
// You can customise Zod schemas for frontmatter and `meta.json` here
|
||||||
|
// see https://fumadocs.dev/docs/mdx/collections
|
||||||
|
export const docs = defineDocs({
|
||||||
|
dir: 'content/docs',
|
||||||
|
docs: {
|
||||||
|
schema: frontmatterSchema,
|
||||||
|
postprocess: {
|
||||||
|
includeProcessedMarkdown: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
meta: {
|
||||||
|
schema: metaSchema,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
mdxOptions: {
|
||||||
|
// MDX options
|
||||||
|
},
|
||||||
|
});
|
||||||
6
documentation/src/app/(home)/layout.tsx
Normal file
6
documentation/src/app/(home)/layout.tsx
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { HomeLayout } from 'fumadocs-ui/layouts/home';
|
||||||
|
import { baseOptions } from '@/lib/layout.shared';
|
||||||
|
|
||||||
|
export default function Layout({ children }: LayoutProps<'/'>) {
|
||||||
|
return <HomeLayout {...baseOptions()}>{children}</HomeLayout>;
|
||||||
|
}
|
||||||
16
documentation/src/app/(home)/page.tsx
Normal file
16
documentation/src/app/(home)/page.tsx
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import Link from 'next/link';
|
||||||
|
|
||||||
|
export default function HomePage() {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col justify-center text-center flex-1">
|
||||||
|
<h1 className="text-2xl font-bold mb-4">Hello World</h1>
|
||||||
|
<p>
|
||||||
|
You can open{' '}
|
||||||
|
<Link href="/docs" className="font-medium underline">
|
||||||
|
/docs
|
||||||
|
</Link>{' '}
|
||||||
|
and see the documentation.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
7
documentation/src/app/api/search/route.ts
Normal file
7
documentation/src/app/api/search/route.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import { source } from '@/lib/source';
|
||||||
|
import { createFromSource } from 'fumadocs-core/search/server';
|
||||||
|
|
||||||
|
export const { GET } = createFromSource(source, {
|
||||||
|
// https://docs.orama.com/docs/orama-js/supported-languages
|
||||||
|
language: 'english',
|
||||||
|
});
|
||||||
47
documentation/src/app/docs/[[...slug]]/page.tsx
Normal file
47
documentation/src/app/docs/[[...slug]]/page.tsx
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { getPageImage, source } from '@/lib/source';
|
||||||
|
import { DocsBody, DocsDescription, DocsPage, DocsTitle } from 'fumadocs-ui/layouts/docs/page';
|
||||||
|
import { notFound } from 'next/navigation';
|
||||||
|
import { getMDXComponents } from '@/mdx-components';
|
||||||
|
import type { Metadata } from 'next';
|
||||||
|
import { createRelativeLink } from 'fumadocs-ui/mdx';
|
||||||
|
|
||||||
|
export default async function Page(props: PageProps<'/docs/[[...slug]]'>) {
|
||||||
|
const params = await props.params;
|
||||||
|
const page = source.getPage(params.slug);
|
||||||
|
if (!page) notFound();
|
||||||
|
|
||||||
|
const MDX = page.data.body;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DocsPage toc={page.data.toc} full={page.data.full}>
|
||||||
|
<DocsTitle>{page.data.title}</DocsTitle>
|
||||||
|
<DocsDescription>{page.data.description}</DocsDescription>
|
||||||
|
<DocsBody>
|
||||||
|
<MDX
|
||||||
|
components={getMDXComponents({
|
||||||
|
// this allows you to link to other pages with relative file paths
|
||||||
|
a: createRelativeLink(source, page),
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</DocsBody>
|
||||||
|
</DocsPage>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generateStaticParams() {
|
||||||
|
return source.generateParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function generateMetadata(props: PageProps<'/docs/[[...slug]]'>): Promise<Metadata> {
|
||||||
|
const params = await props.params;
|
||||||
|
const page = source.getPage(params.slug);
|
||||||
|
if (!page) notFound();
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: page.data.title,
|
||||||
|
description: page.data.description,
|
||||||
|
openGraph: {
|
||||||
|
images: getPageImage(page).url,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
11
documentation/src/app/docs/layout.tsx
Normal file
11
documentation/src/app/docs/layout.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { source } from '@/lib/source';
|
||||||
|
import { DocsLayout } from 'fumadocs-ui/layouts/docs';
|
||||||
|
import { baseOptions } from '@/lib/layout.shared';
|
||||||
|
|
||||||
|
export default function Layout({ children }: LayoutProps<'/docs'>) {
|
||||||
|
return (
|
||||||
|
<DocsLayout tree={source.getPageTree()} {...baseOptions()}>
|
||||||
|
{children}
|
||||||
|
</DocsLayout>
|
||||||
|
);
|
||||||
|
}
|
||||||
3
documentation/src/app/global.css
Normal file
3
documentation/src/app/global.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@import 'tailwindcss';
|
||||||
|
@import 'fumadocs-ui/css/neutral.css';
|
||||||
|
@import 'fumadocs-ui/css/preset.css';
|
||||||
17
documentation/src/app/layout.tsx
Normal file
17
documentation/src/app/layout.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { RootProvider } from 'fumadocs-ui/provider/next';
|
||||||
|
import './global.css';
|
||||||
|
import { Inter } from 'next/font/google';
|
||||||
|
|
||||||
|
const inter = Inter({
|
||||||
|
subsets: ['latin'],
|
||||||
|
});
|
||||||
|
|
||||||
|
export default function Layout({ children }: LayoutProps<'/'>) {
|
||||||
|
return (
|
||||||
|
<html lang="en" className={inter.className} suppressHydrationWarning>
|
||||||
|
<body className="flex flex-col min-h-screen">
|
||||||
|
<RootProvider>{children}</RootProvider>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
10
documentation/src/app/llms-full.txt/route.ts
Normal file
10
documentation/src/app/llms-full.txt/route.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { getLLMText, source } from '@/lib/source';
|
||||||
|
|
||||||
|
export const revalidate = false;
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
const scan = source.getPages().map(getLLMText);
|
||||||
|
const scanned = await Promise.all(scan);
|
||||||
|
|
||||||
|
return new Response(scanned.join('\n\n'));
|
||||||
|
}
|
||||||
27
documentation/src/app/og/docs/[...slug]/route.tsx
Normal file
27
documentation/src/app/og/docs/[...slug]/route.tsx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { getPageImage, source } from '@/lib/source';
|
||||||
|
import { notFound } from 'next/navigation';
|
||||||
|
import { ImageResponse } from 'next/og';
|
||||||
|
import { generate as DefaultImage } from 'fumadocs-ui/og';
|
||||||
|
|
||||||
|
export const revalidate = false;
|
||||||
|
|
||||||
|
export async function GET(_req: Request, { params }: RouteContext<'/og/docs/[...slug]'>) {
|
||||||
|
const { slug } = await params;
|
||||||
|
const page = source.getPage(slug.slice(0, -1));
|
||||||
|
if (!page) notFound();
|
||||||
|
|
||||||
|
return new ImageResponse(
|
||||||
|
<DefaultImage title={page.data.title} description={page.data.description} site="My App" />,
|
||||||
|
{
|
||||||
|
width: 1200,
|
||||||
|
height: 630,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function generateStaticParams() {
|
||||||
|
return source.getPages().map((page) => ({
|
||||||
|
lang: page.locale,
|
||||||
|
slug: getPageImage(page).segments,
|
||||||
|
}));
|
||||||
|
}
|
||||||
9
documentation/src/lib/layout.shared.tsx
Normal file
9
documentation/src/lib/layout.shared.tsx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
|
||||||
|
|
||||||
|
export function baseOptions(): BaseLayoutProps {
|
||||||
|
return {
|
||||||
|
nav: {
|
||||||
|
title: 'My App',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
27
documentation/src/lib/source.ts
Normal file
27
documentation/src/lib/source.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import { docs } from 'fumadocs-mdx:collections/server';
|
||||||
|
import { type InferPageType, loader } from 'fumadocs-core/source';
|
||||||
|
import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
|
||||||
|
|
||||||
|
// See https://fumadocs.dev/docs/headless/source-api for more info
|
||||||
|
export const source = loader({
|
||||||
|
baseUrl: '/docs',
|
||||||
|
source: docs.toFumadocsSource(),
|
||||||
|
plugins: [lucideIconsPlugin()],
|
||||||
|
});
|
||||||
|
|
||||||
|
export function getPageImage(page: InferPageType<typeof source>) {
|
||||||
|
const segments = [...page.slugs, 'image.png'];
|
||||||
|
|
||||||
|
return {
|
||||||
|
segments,
|
||||||
|
url: `/og/docs/${segments.join('/')}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getLLMText(page: InferPageType<typeof source>) {
|
||||||
|
const processed = await page.data.getText('processed');
|
||||||
|
|
||||||
|
return `# ${page.data.title}
|
||||||
|
|
||||||
|
${processed}`;
|
||||||
|
}
|
||||||
9
documentation/src/mdx-components.tsx
Normal file
9
documentation/src/mdx-components.tsx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import defaultMdxComponents from 'fumadocs-ui/mdx';
|
||||||
|
import type { MDXComponents } from 'mdx/types';
|
||||||
|
|
||||||
|
export function getMDXComponents(components?: MDXComponents): MDXComponents {
|
||||||
|
return {
|
||||||
|
...defaultMdxComponents,
|
||||||
|
...components,
|
||||||
|
};
|
||||||
|
}
|
||||||
46
documentation/tsconfig.json
Normal file
46
documentation/tsconfig.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"target": "ESNext",
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"dom.iterable",
|
||||||
|
"esnext"
|
||||||
|
],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"incremental": true,
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"./src/*"
|
||||||
|
],
|
||||||
|
"fumadocs-mdx:collections/*": [
|
||||||
|
".source/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user