Skip to content

Commit 4a85d85

Browse files
feat: replaces starlight with fumadocs
1 parent c38a33a commit 4a85d85

Some content is hidden

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

46 files changed

+2054
-2018
lines changed

docs/.gitignore

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
1-
# build output
2-
dist/
3-
# generated types
4-
.astro/
1+
# deps
2+
/node_modules
53

6-
# dependencies
7-
node_modules/
4+
# generated content
5+
.contentlayer
6+
.content-collections
7+
.source
88

9-
# logs
9+
# test & build
10+
/coverage
11+
/.next/
12+
/out/
13+
/build
14+
*.tsbuildinfo
15+
16+
# misc
17+
.DS_Store
18+
*.pem
19+
/.pnp
20+
.pnp.js
1021
npm-debug.log*
1122
yarn-debug.log*
1223
yarn-error.log*
13-
pnpm-debug.log*
14-
1524

16-
# environment variables
17-
.env
18-
.env.production
19-
20-
# macOS-specific files
21-
.DS_Store
25+
# others
26+
.env*.local
27+
.vercel
28+
next-env.d.ts

docs/.vscode/extensions.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/.vscode/launch.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/app/api/search/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { source } from '@/lib/source';
2+
import { createFromSource } from 'fumadocs-core/search/server';
3+
4+
export const { GET } = createFromSource(source);

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { source } from "@/lib/source";
2+
import {
3+
DocsPage,
4+
DocsBody,
5+
DocsDescription,
6+
DocsTitle,
7+
} from "fumadocs-ui/page";
8+
import { notFound } from "next/navigation";
9+
import defaultMdxComponents, { createRelativeLink } from "fumadocs-ui/mdx";
10+
11+
export default async function Page(props: {
12+
params: Promise<{ slug?: string[] }>;
13+
}) {
14+
const params = await props.params;
15+
const page = source.getPage(params.slug);
16+
if (!page) notFound();
17+
18+
const MDXContent = page.data.body;
19+
20+
return (
21+
<DocsPage
22+
toc={page.data.toc}
23+
full={page.data.full}
24+
editOnGithub={{
25+
owner: "muppet-dev",
26+
repo: "muppet",
27+
sha: "main",
28+
path: `/docs/content/docs/${page.file.path}`,
29+
}}
30+
>
31+
<DocsTitle>{page.data.title}</DocsTitle>
32+
<DocsDescription>{page.data.description}</DocsDescription>
33+
<DocsBody>
34+
<MDXContent
35+
components={{
36+
...defaultMdxComponents,
37+
// this allows you to link to other pages with relative file paths
38+
a: createRelativeLink(source, page),
39+
// you can add other MDX components here
40+
}}
41+
/>
42+
</DocsBody>
43+
</DocsPage>
44+
);
45+
}
46+
47+
export async function generateStaticParams() {
48+
return source.generateParams();
49+
}
50+
51+
export async function generateMetadata(props: {
52+
params: Promise<{ slug?: string[] }>;
53+
}) {
54+
const params = await props.params;
55+
const page = source.getPage(params.slug);
56+
if (!page) notFound();
57+
58+
return {
59+
title: page.data.title,
60+
description: page.data.description,
61+
};
62+
}

docs/app/docs/layout.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { DocsLayout } from "fumadocs-ui/layouts/docs";
2+
import type { ReactNode } from "react";
3+
import { baseOptions } from "@/app/layout.config";
4+
import { source } from "@/lib/source";
5+
6+
export default function Layout({ children }: { children: ReactNode }) {
7+
return (
8+
<DocsLayout tree={source.pageTree} {...baseOptions}>
9+
{children}
10+
</DocsLayout>
11+
);
12+
}

docs/app/global.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import 'tailwindcss';
2+
@import 'fumadocs-ui/css/neutral.css';
3+
@import 'fumadocs-ui/css/preset.css';
4+
5+
@source '../node_modules/fumadocs-ui/dist/**/*.js';

docs/app/layout.config.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Logo } from "@/components/Logo";
2+
import { FaBluesky, FaXTwitter } from "react-icons/fa6";
3+
import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared";
4+
5+
/**
6+
* Shared layout configurations
7+
*
8+
* you can customise layouts individually from:
9+
* Home Layout: app/(home)/layout.tsx
10+
* Docs Layout: app/docs/layout.tsx
11+
*/
12+
export const baseOptions: BaseLayoutProps = {
13+
nav: {
14+
title: <Logo />,
15+
},
16+
links: [
17+
{
18+
type: "icon",
19+
icon: <FaBluesky />,
20+
text: "X",
21+
url: "https://x.com/muppetdev",
22+
},
23+
{
24+
type: "icon",
25+
icon: <FaXTwitter />,
26+
text: "BlueSky",
27+
url: "https://bsky.app/profile/muppet.dev",
28+
},
29+
],
30+
githubUrl: "https://github.com/muppet-dev/muppet",
31+
};

docs/app/layout.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import './global.css';
2+
import { RootProvider } from 'fumadocs-ui/provider';
3+
import { Inter } from 'next/font/google';
4+
import type { ReactNode } from 'react';
5+
6+
const inter = Inter({
7+
subsets: ['latin'],
8+
});
9+
10+
export default function Layout({ children }: { children: ReactNode }) {
11+
return (
12+
<html lang="en" className={inter.className} suppressHydrationWarning>
13+
<body className="flex flex-col min-h-screen">
14+
<RootProvider>{children}</RootProvider>
15+
</body>
16+
</html>
17+
);
18+
}

docs/app/llms.txt/route.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as fs from "node:fs/promises";
2+
import fg from "fast-glob";
3+
import matter from "gray-matter";
4+
import { remark } from "remark";
5+
import remarkGfm from "remark-gfm";
6+
import remarkStringify from "remark-stringify";
7+
import remarkMdx from "remark-mdx";
8+
import { remarkInclude } from "fumadocs-mdx/config";
9+
10+
export const revalidate = false;
11+
12+
export async function GET() {
13+
// all scanned content
14+
const files = await fg(["./content/docs/**/*.{md,mdx}"]);
15+
16+
const scan = files.map(async (file) => {
17+
const fileContent = await fs.readFile(file);
18+
const { content, data } = matter(fileContent.toString());
19+
20+
const processed = await processContent(content);
21+
return `file: ${file}
22+
meta: ${JSON.stringify(data, null, 2)}
23+
24+
${processed}`;
25+
});
26+
27+
const scanned = await Promise.all(scan);
28+
29+
return new Response(scanned.join("\n\n"));
30+
}
31+
32+
async function processContent(content: string): Promise<string> {
33+
const file = await remark()
34+
.use(remarkMdx)
35+
// https://fumadocs.vercel.app/docs/mdx/include
36+
.use(remarkInclude)
37+
// gfm styles
38+
.use(remarkGfm)
39+
// .use(your remark plugins)
40+
.use(remarkStringify) // to string
41+
.process(content);
42+
43+
return String(file);
44+
}

0 commit comments

Comments
 (0)