40 lines
1020 B
TypeScript
40 lines
1020 B
TypeScript
import { source } from '@/lib/source';
|
|
import {
|
|
DocsBody,
|
|
DocsDescription,
|
|
DocsPage,
|
|
DocsTitle,
|
|
} from 'fumadocs-ui/layouts/docs/page';
|
|
import { notFound } from 'next/navigation';
|
|
import { getMDXComponents } from '@/components/mdx';
|
|
import { createRelativeLink } from 'fumadocs-ui/mdx';
|
|
|
|
/** Render a single docs page for a given slug + locale (shared by both trees). */
|
|
export function RenderDocsPage({
|
|
slug,
|
|
lang,
|
|
}: {
|
|
slug: string[] | undefined;
|
|
lang: string;
|
|
}) {
|
|
const page = source.getPage(slug, lang);
|
|
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({
|
|
// allows linking to other pages with relative file paths
|
|
a: createRelativeLink(source, page),
|
|
})}
|
|
/>
|
|
</DocsBody>
|
|
</DocsPage>
|
|
);
|
|
}
|