mirror of
https://github.com/zap-proto/zap-proto.github.io.git
synced 2026-10-30 15:02:56 +00:00
- Add SchemaTabs component with syntax highlighting for both formats - Update all docs pages to use SchemaTabs with both syntaxes - Register SchemaTabs in MDX components for docs pages - Add file ID annotations to capnp examples to show the difference
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import { source } from '@/lib/source';
|
|
import {
|
|
DocsPage,
|
|
DocsBody,
|
|
DocsDescription,
|
|
DocsTitle,
|
|
} from '@hanzo/docs-radix-ui/page';
|
|
import { notFound } from 'next/navigation';
|
|
import defaultMdxComponents from '@hanzo/docs-radix-ui/mdx';
|
|
import { Tab, Tabs } from '@hanzo/docs-radix-ui/components/tabs';
|
|
import { SchemaTabs } from '@/components/schema-tabs';
|
|
import type { MDXContent } from 'mdx/types';
|
|
import type { TOCItemType } from '@hanzo/docs-core/toc';
|
|
|
|
interface ExtendedPageData {
|
|
body: MDXContent;
|
|
toc: TOCItemType[];
|
|
full?: boolean;
|
|
title?: string;
|
|
description?: string;
|
|
}
|
|
|
|
export default async function Page(props: {
|
|
params: Promise<{ slug?: string[] }>;
|
|
}) {
|
|
const params = await props.params;
|
|
const page = source.getPage(params.slug);
|
|
if (!page) notFound();
|
|
|
|
const data = page.data as ExtendedPageData;
|
|
const MDX = data.body;
|
|
|
|
return (
|
|
<DocsPage toc={data.toc} full={data.full}>
|
|
<DocsTitle>{data.title}</DocsTitle>
|
|
<DocsDescription>{data.description}</DocsDescription>
|
|
<DocsBody>
|
|
<MDX components={{ ...defaultMdxComponents, Tab, Tabs, SchemaTabs }} />
|
|
</DocsBody>
|
|
</DocsPage>
|
|
);
|
|
}
|
|
|
|
export async function generateStaticParams() {
|
|
return source.generateParams();
|
|
}
|
|
|
|
export async function generateMetadata(props: {
|
|
params: Promise<{ slug?: string[] }>;
|
|
}) {
|
|
const params = await props.params;
|
|
const page = source.getPage(params.slug);
|
|
if (!page) notFound();
|
|
|
|
return {
|
|
title: page.data.title,
|
|
description: page.data.description,
|
|
};
|
|
}
|