mirror of
https://github.com/shadcn-ui/taxonomy
synced 2026-05-24 09:48:32 +00:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { notFound } from "next/navigation"
|
|
import { allDocs } from "contentlayer/generated"
|
|
|
|
import { getTableOfContents } from "@/lib/toc"
|
|
import { Mdx } from "@/components/docs/mdx"
|
|
import { DashboardTableOfContents } from "@/components/docs/toc"
|
|
import { DocsPageHeader } from "@/components/docs/page-header"
|
|
import { DocsPager } from "@/components/docs/pager"
|
|
import "@/styles/mdx.css"
|
|
|
|
interface DocPageProps {
|
|
params: {
|
|
slug: string[]
|
|
}
|
|
}
|
|
|
|
export async function generateStaticParams(): Promise<
|
|
DocPageProps["params"][]
|
|
> {
|
|
return allDocs.map((doc) => ({
|
|
slug: doc.slugAsParams.split("/"),
|
|
}))
|
|
}
|
|
|
|
export default async function DocPage({ params }: DocPageProps) {
|
|
const slug = params?.slug?.join("/") || ""
|
|
const doc = allDocs.find((doc) => doc.slugAsParams === slug)
|
|
|
|
if (!doc) {
|
|
notFound()
|
|
}
|
|
|
|
const toc = await getTableOfContents(doc.body.raw)
|
|
|
|
return (
|
|
<main className="relative py-6 lg:gap-10 lg:py-10 xl:grid xl:grid-cols-[1fr_300px]">
|
|
<div className="mx-auto w-full min-w-0">
|
|
<DocsPageHeader heading={doc.title} text={doc.description} />
|
|
<Mdx code={doc.body.code} />
|
|
<hr className="my-4 border-slate-200 md:my-6" />
|
|
<DocsPager doc={doc} />
|
|
</div>
|
|
<div className="hidden text-sm xl:block">
|
|
<div className="sticky top-16 -mt-10 max-h-[calc(var(--vh)-4rem)] overflow-y-auto pt-10">
|
|
<DashboardTableOfContents toc={toc} />
|
|
</div>
|
|
</div>
|
|
</main>
|
|
)
|
|
}
|