Skip to content

Commit 4e78e74

Browse files
author
Dan Costello
committed
Initial commit from Create Fumadocs App
0 parents  commit 4e78e74

21 files changed

Lines changed: 5360 additions & 0 deletions

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "next/typescript"]
3+
}

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# deps
2+
/node_modules
3+
4+
# generated content
5+
.contentlayer
6+
.content-collections
7+
.source
8+
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
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
# others
26+
.env*.local
27+
.vercel
28+
next-env.d.ts

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# docs
2+
3+
This is a Next.js application generated with
4+
[Create Fumadocs](https://github.com/fuma-nama/fumadocs).
5+
6+
Run development server:
7+
8+
```bash
9+
npm run dev
10+
# or
11+
pnpm dev
12+
# or
13+
yarn dev
14+
```
15+
16+
Open http://localhost:3000 with your browser to see the result.
17+
18+
## Learn More
19+
20+
To learn more about Next.js and Fumadocs, take a look at the following
21+
resources:
22+
23+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
24+
features and API.
25+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
26+
- [Fumadocs](https://fumadocs.vercel.app) - learn about Fumadocs

app/(home)/layout.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ReactNode } from 'react';
2+
import { HomeLayout } from 'fumadocs-ui/layouts/home';
3+
import { baseOptions } from '@/app/layout.config';
4+
5+
export default function Layout({ children }: { children: ReactNode }) {
6+
return <HomeLayout {...baseOptions}>{children}</HomeLayout>;
7+
}

app/(home)/page.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import Link from 'next/link';
2+
3+
export default function HomePage() {
4+
return (
5+
<main className="flex flex-1 flex-col justify-center text-center">
6+
<h1 className="mb-4 text-2xl font-bold">Hello World</h1>
7+
<p className="text-fd-muted-foreground">
8+
You can open{' '}
9+
<Link
10+
href="/docs"
11+
className="text-fd-foreground font-semibold underline"
12+
>
13+
/docs
14+
</Link>{' '}
15+
and see the documentation.
16+
</p>
17+
</main>
18+
);
19+
}

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);

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 { createRelativeLink } from 'fumadocs-ui/mdx';
10+
import { getMDXComponents } from '@/mdx-components';
11+
12+
export default async function Page(props: {
13+
params: Promise<{ slug?: string[] }>;
14+
}) {
15+
const params = await props.params;
16+
const page = source.getPage(params.slug);
17+
if (!page) notFound();
18+
19+
const MDXContent = page.data.body;
20+
21+
return (
22+
<DocsPage toc={page.data.toc} full={page.data.full}>
23+
<DocsTitle>{page.data.title}</DocsTitle>
24+
<DocsDescription>{page.data.description}</DocsDescription>
25+
<DocsBody>
26+
<MDXContent
27+
components={getMDXComponents({
28+
// this allows you to link to other pages with relative file paths
29+
a: createRelativeLink(source, page),
30+
})}
31+
/>
32+
</DocsBody>
33+
</DocsPage>
34+
);
35+
}
36+
37+
export async function generateStaticParams() {
38+
return source.generateParams();
39+
}
40+
41+
export async function generateMetadata(props: {
42+
params: Promise<{ slug?: string[] }>;
43+
}) {
44+
const params = await props.params;
45+
const page = source.getPage(params.slug);
46+
if (!page) notFound();
47+
48+
return {
49+
title: page.data.title,
50+
description: page.data.description,
51+
};
52+
}

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+
}

app/global.css

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

app/layout.config.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
2+
3+
/**
4+
* Shared layout configurations
5+
*
6+
* you can customise layouts individually from:
7+
* Home Layout: app/(home)/layout.tsx
8+
* Docs Layout: app/docs/layout.tsx
9+
*/
10+
export const baseOptions: BaseLayoutProps = {
11+
nav: {
12+
title: (
13+
<>
14+
<svg
15+
width="24"
16+
height="24"
17+
xmlns="http://www.w3.org/2000/svg"
18+
aria-label="Logo"
19+
>
20+
<circle cx={12} cy={12} r={12} fill="currentColor" />
21+
</svg>
22+
My App
23+
</>
24+
),
25+
},
26+
links: [
27+
{
28+
text: 'Documentation',
29+
url: '/docs',
30+
active: 'nested-url',
31+
},
32+
],
33+
};

0 commit comments

Comments
 (0)