Skip to content

Commit 05782f5

Browse files
authored
Create documentation website (#6)
1 parent 7b75d7c commit 05782f5

33 files changed

+5851
-84
lines changed

.github/labeller.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
- changed-files:
77
- any-glob-to-any-file: ['examples/**']
88

9+
'website':
10+
- changed-files:
11+
- any-glob-to-any-file: ['website/**']
12+
913
'tests':
1014
- changed-files:
1115
- any-glob-to-any-file: ['packages/**/*.test.ts']

.github/labels.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
description: Updates or additions to example apps
1919
color: 009688
2020

21+
- name: website
22+
description: Updates to the documentation website
23+
color: 0ea5e9
24+
2125
- name: tests
2226
description: Modifications, additions, or fixes related to testing
2327
color: 00bfa5

pnpm-lock.yaml

Lines changed: 4621 additions & 84 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
packages:
22
- examples/*
33
- packages/*
4+
- website
45

56
onlyBuiltDependencies:
67
- esbuild

website/.gitignore

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# deps
2+
/node_modules
3+
4+
# generated content
5+
.source
6+
7+
# test & build
8+
/coverage
9+
/.next/
10+
/out/
11+
/build
12+
*.tsbuildinfo
13+
14+
# misc
15+
.DS_Store
16+
*.pem
17+
/.pnp
18+
.pnp.js
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*
22+
23+
# others
24+
.env*.local
25+
.vercel
26+
next-env.d.ts

website/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# website
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+
## Explore
19+
20+
In the project, you can see:
21+
22+
- `lib/source.ts`: Code for content source adapter, [`loader()`](https://fumadocs.dev/docs/headless/source-api) provides the interface to access your content.
23+
- `lib/layout.shared.tsx`: Shared options for layouts, optional but preferred to keep.
24+
25+
| Route | Description |
26+
| ------------------------- | ------------------------------------------------------ |
27+
| `app/(home)` | The route group for your landing page and other pages. |
28+
| `app/docs` | The documentation layout and pages. |
29+
| `app/api/search/route.ts` | The Route Handler for search. |
30+
31+
### Fumadocs MDX
32+
33+
A `source.config.ts` config file has been included, you can customise different options like frontmatter schema.
34+
35+
Read the [Introduction](https://fumadocs.dev/docs/mdx) for further details.
36+
37+
## Learn More
38+
39+
To learn more about Next.js and Fumadocs, take a look at the following
40+
resources:
41+
42+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js
43+
features and API.
44+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
45+
- [Fumadocs](https://fumadocs.dev) - learn about Fumadocs
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { getMDXComponents } from 'components/mdx';
2+
import {
3+
DocsBody,
4+
DocsDescription,
5+
DocsPage,
6+
DocsTitle,
7+
MarkdownCopyButton,
8+
ViewOptionsPopover,
9+
} from 'fumadocs-ui/layouts/docs/page';
10+
import { createRelativeLink } from 'fumadocs-ui/mdx';
11+
import { gitConfig } from 'lib/layout.shared';
12+
import { getPageImage, source } from 'lib/source';
13+
import type { Metadata } from 'next';
14+
import { notFound } from 'next/navigation';
15+
16+
export default async function Page({ params }: PageProps<'/[...slug]'>) {
17+
const { slug } = await params;
18+
const page = source.getPage(slug);
19+
if (!page) notFound();
20+
21+
const MDX = page.data.body;
22+
23+
return (
24+
<DocsPage toc={page.data.toc} full={page.data.full}>
25+
<DocsTitle>{page.data.title}</DocsTitle>
26+
<DocsDescription className="mb-0">{page.data.description}</DocsDescription>
27+
<div className="flex flex-row gap-2 items-center border-b pb-6">
28+
<MarkdownCopyButton markdownUrl={`${page.url}.mdx`} />
29+
<ViewOptionsPopover
30+
markdownUrl={`${page.url}.mdx`}
31+
githubUrl={`https://github.com/${gitConfig.user}/${gitConfig.repo}/blob/${gitConfig.branch}/content/docs/${page.path}`}
32+
/>
33+
</div>
34+
<DocsBody>
35+
<MDX
36+
components={getMDXComponents({
37+
// this allows you to link to other pages with relative file paths
38+
a: createRelativeLink(source, page),
39+
})}
40+
/>
41+
</DocsBody>
42+
</DocsPage>
43+
);
44+
}
45+
46+
export async function generateStaticParams() {
47+
return source.generateParams();
48+
}
49+
50+
export async function generateMetadata({ params }: PageProps<'/[...slug]'>): Promise<Metadata> {
51+
const { slug } = await params;
52+
const page = source.getPage(slug);
53+
if (!page) notFound();
54+
55+
return {
56+
title: page.data.title,
57+
description: page.data.description,
58+
openGraph: {
59+
images: getPageImage(page).url,
60+
},
61+
};
62+
}

website/app/(docs)/layout.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { DocsLayout, DocsLayoutProps } from 'fumadocs-ui/layouts/docs';
2+
import { baseOptions } from 'lib/layout.shared';
3+
import { source } from 'lib/source';
4+
import { Metadata } from 'next';
5+
6+
function docsOptions(): DocsLayoutProps {
7+
return {
8+
...baseOptions(),
9+
tree: source.getPageTree(),
10+
};
11+
}
12+
13+
export default function Layout({ children }: LayoutProps<'/'>) {
14+
return <DocsLayout {...docsOptions()}>{children}</DocsLayout>;
15+
}
16+
17+
export const metadata: Metadata = {
18+
title: {
19+
template: '%s - SayKit',
20+
default: 'SayKit',
21+
},
22+
};

website/app/api/search/route.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createFromSource } from 'fumadocs-core/search/server';
2+
import { source } from 'lib/source';
3+
4+
export const { GET } = createFromSource(source, {
5+
// https://docs.orama.com/docs/orama-js/supported-languages
6+
language: 'english',
7+
});

website/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/ruby.css';
3+
@import 'fumadocs-ui/css/preset.css';

0 commit comments

Comments
 (0)