Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/labeller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
- changed-files:
- any-glob-to-any-file: ['examples/**']

'website':
- changed-files:
- any-glob-to-any-file: ['website/**']

'tests':
- changed-files:
- any-glob-to-any-file: ['packages/**/*.test.ts']
Expand Down
4 changes: 4 additions & 0 deletions .github/labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
description: Updates or additions to example apps
color: 009688

- name: website
description: Updates to the documentation website
color: 0ea5e9

- name: tests
description: Modifications, additions, or fixes related to testing
color: 00bfa5
Expand Down
4,705 changes: 4,621 additions & 84 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
packages:
- examples/*
- packages/*
- website

onlyBuiltDependencies:
- esbuild
26 changes: 26 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -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 changes: 45 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# website

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
62 changes: 62 additions & 0 deletions website/app/(docs)/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { getMDXComponents } from 'components/mdx';
import {
DocsBody,
DocsDescription,
DocsPage,
DocsTitle,
MarkdownCopyButton,
ViewOptionsPopover,
} from 'fumadocs-ui/layouts/docs/page';
import { createRelativeLink } from 'fumadocs-ui/mdx';
import { gitConfig } from 'lib/layout.shared';
import { getPageImage, source } from 'lib/source';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';

export default async function Page({ params }: PageProps<'/[...slug]'>) {
const { slug } = await params;
const page = source.getPage(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 className="mb-0">{page.data.description}</DocsDescription>
<div className="flex flex-row gap-2 items-center border-b pb-6">
<MarkdownCopyButton markdownUrl={`${page.url}.mdx`} />
<ViewOptionsPopover
markdownUrl={`${page.url}.mdx`}
githubUrl={`https://github.com/${gitConfig.user}/${gitConfig.repo}/blob/${gitConfig.branch}/content/docs/${page.path}`}
/>
</div>
<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({ params }: PageProps<'/[...slug]'>): Promise<Metadata> {
const { slug } = await params;
const page = source.getPage(slug);
if (!page) notFound();

return {
title: page.data.title,
description: page.data.description,
openGraph: {
images: getPageImage(page).url,
},
};
}
22 changes: 22 additions & 0 deletions website/app/(docs)/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { DocsLayout, DocsLayoutProps } from 'fumadocs-ui/layouts/docs';
import { baseOptions } from 'lib/layout.shared';
import { source } from 'lib/source';
import { Metadata } from 'next';

function docsOptions(): DocsLayoutProps {
return {
...baseOptions(),
tree: source.getPageTree(),
};
}

export default function Layout({ children }: LayoutProps<'/'>) {
return <DocsLayout {...docsOptions()}>{children}</DocsLayout>;
}

export const metadata: Metadata = {
title: {
template: '%s - SayKit',
default: 'SayKit',
},
};
7 changes: 7 additions & 0 deletions website/app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createFromSource } from 'fumadocs-core/search/server';
import { source } from 'lib/source';

export const { GET } = createFromSource(source, {
// https://docs.orama.com/docs/orama-js/supported-languages
language: 'english',
});
3 changes: 3 additions & 0 deletions website/app/global.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import 'tailwindcss';
@import 'fumadocs-ui/css/ruby.css';
@import 'fumadocs-ui/css/preset.css';
17 changes: 17 additions & 0 deletions website/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 changes: 10 additions & 0 deletions website/app/llms-full.txt/route.ts
Original file line number Diff line number Diff line change
@@ -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'));
}
28 changes: 28 additions & 0 deletions website/app/og/[...slug]/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ImageResponse } from '@takumi-rs/image-response';
import { generate as DefaultImage } from 'fumadocs-ui/og/takumi';
import { getPageImage, source } from 'lib/source';
import { notFound } from 'next/navigation';

export const revalidate = false;

export async function GET(_req: Request, { params }: RouteContext<'/og/[...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="SayKit" />,
{
width: 1200,
height: 630,
format: 'webp',
},
);
}

export function generateStaticParams() {
return source.getPages().map((page) => ({
lang: page.locale,
slug: getPageImage(page).segments,
}));
}
21 changes: 21 additions & 0 deletions website/components/mdx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as stepsComponents from 'fumadocs-ui/components/steps';
import * as tabsComponents from 'fumadocs-ui/components/tabs';
import defaultMdxComponents from 'fumadocs-ui/mdx';
import type { MDXComponents } from 'mdx/types';
import * as mermaidComponents from './mermaid';

export function getMDXComponents(components?: MDXComponents) {
return {
...defaultMdxComponents,
...tabsComponents,
...stepsComponents,
...mermaidComponents,
...components,
} satisfies MDXComponents;
}

export const useMDXComponents = getMDXComponents;

declare global {
type MDXProvidedComponents = ReturnType<typeof getMDXComponents>;
}
21 changes: 21 additions & 0 deletions website/components/mermaid.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { renderMermaidSVG } from 'beautiful-mermaid';
import { CodeBlock, Pre } from 'fumadocs-ui/components/codeblock';

export async function Mermaid({ chart }: { chart: string }) {
try {
const svg = renderMermaidSVG(chart, {
bg: 'var(--color-fd-background)',
fg: 'var(--color-fd-foreground)',
interactive: true,
transparent: true,
});

return <div dangerouslySetInnerHTML={{ __html: svg }} />;
} catch {
return (
<CodeBlock title="Mermaid">
<Pre>{chart}</Pre>
</CodeBlock>
);
}
}
Loading
Loading