Server Entry
Accessing collection outputs from server.
Usage
While you can access the collections directly from entry file, we suggest using it with loader().
import { docs } from 'fumadocs-mdx:collections/server';
import { loader } from 'fumadocs-core/source';
// raw collection
console.log(docs);
export const source = loader({
baseUrl: '/docs',
source: docs.toFumadocsSource(),
});Examples
import { source } from '@/lib/source';
const page = source.getPage(['slugs']);
if (page) {
// access page data
console.log(page.data);
// frontmatter properties are also available
console.log(page.data.title);
}To render the page (on RSC), use page.data.body as a component.
import { getMDXComponents } from '@/mdx-components';
const MDX = page.data.body;
// set your MDX components with `components` prop
return <MDX components={getMDXComponents()} />;How is this guide?
Last updated on
