DocsPage
A docs page with a table of contents, breadcrumb and previous/next links.
Installation
npx shadcn@latest add @docscn/docs-pageUsage
import { notFound } from "next/navigation";
import { getMDXComponents } from "@/components/mdx";
import {
DocsBody,
DocsDescription,
DocsPage,
DocsTitle,
} from "@/components/docs/layouts/docs/page";
import { createRelativeLink } from "@/components/docs/mdx";
import { source } from "@/lib/source";
export default async function Page(props: PageProps<"/docs/[[...slug]]">) {
const params = await props.params;
const page = source.getPage(params.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>{page.data.description}</DocsDescription>
<DocsBody>
<MDX
components={getMDXComponents({ a: createRelativeLink(source, page) })}
/>
</DocsBody>
</DocsPage>
);
}Use it inside DocsLayout. DocsBody adds the docs-typeset class.
Props
Prop
Type
The rest are passed to the page's <article>.
Other exports
EditOnGitHub: a link button, e.g.<EditOnGitHub href="https://github.com/…/edit/main/content/docs/index.mdx" />.PageLastUpdate: showsLast updated on <date>in the reader's locale, from adateprop.PageBreadcrumbandPageFooter: the breadcrumb and footer on their own.MarkdownCopyButtonandViewOptionsPopover: the page actions.useDocsPage(): returns{ full }.