mirror of
https://github.com/ReaJason/MemShellParty.git
synced 2026-09-22 07:00:43 +08:00
57 lines
1.8 KiB
TypeScript
57 lines
1.8 KiB
TypeScript
import browserCollections from "fumadocs-mdx:collections/browser";
|
|
import { useFumadocsLoader } from "fumadocs-core/source/client";
|
|
import { ImageZoom } from "fumadocs-ui/components/image-zoom";
|
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
import {
|
|
DocsBody,
|
|
DocsDescription,
|
|
DocsPage,
|
|
DocsTitle,
|
|
} from "fumadocs-ui/layouts/docs/page";
|
|
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
import { baseOptions } from "@/lib/layout.shared";
|
|
import { source } from "@/lib/source";
|
|
import type { Route } from "./+types/page";
|
|
|
|
export async function loader({ params }: Route.LoaderArgs) {
|
|
const slugs = params["*"].split("/").filter((v) => v.length > 0);
|
|
const page = source.getPage(slugs);
|
|
if (!page) throw new Response("Not found", { status: 404 });
|
|
|
|
return {
|
|
path: page.path,
|
|
pageTree: await source.serializePageTree(source.pageTree),
|
|
};
|
|
}
|
|
|
|
const clientLoader = browserCollections.docs.createClientLoader({
|
|
component({ toc, default: Mdx, frontmatter }) {
|
|
return (
|
|
<DocsPage toc={toc}>
|
|
<title>{frontmatter.title}</title>
|
|
<meta name="description" content={frontmatter.description} />
|
|
<DocsTitle>{frontmatter.title}</DocsTitle>
|
|
<DocsDescription>{frontmatter.description}</DocsDescription>
|
|
<DocsBody>
|
|
<Mdx
|
|
components={{
|
|
...defaultMdxComponents,
|
|
img: (props) => <ImageZoom {...(props as any)} />,
|
|
}}
|
|
/>
|
|
</DocsBody>
|
|
</DocsPage>
|
|
);
|
|
},
|
|
});
|
|
|
|
export default function Page({ loaderData }: Route.ComponentProps) {
|
|
const Content = clientLoader.getComponent(loaderData.path);
|
|
const { pageTree } = useFumadocsLoader(loaderData);
|
|
return (
|
|
<DocsLayout {...baseOptions()} tree={pageTree}>
|
|
<Content />
|
|
</DocsLayout>
|
|
);
|
|
}
|