Source
Setup sources for Loader API
Overview
loader() accepts different content sources based on a source interface.
Multiple Sources
Use multiple to combine multiple sources into one.
import { loader, multiple } from 'fumadocs-core/source';
import { openapiPlugin, openapiSource } from 'fumadocs-openapi/server';
import { blog, docs } from 'fumadocs-mdx:collections/server';
import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
export const source = loader(
multiple({
docs: docs.toFumadocsSource(),
openapi: blog.toFumadocsSource(),
}),
{
baseUrl: '/docs',
},
);To access properties exclusive to each source:
const page = source.getPage(['...']);
if (page.data.type === 'docs') {
console.log(page.data);
} else {
console.log(page.data);
}Custom Source
To plug your own content source, create a Source object.
Since Loader API doesn't rely on file system, file paths only allow virtual paths like file.mdx and content/file.mdx, ./file.mdx and D://content/file.mdx are not allowed.
import { } from 'fumadocs-core/source';
export function (): <{
: { : string; : string[] }; // Your custom type
: { : string; ?: string }; // Your custom type
}> {
return {
: [
{
: 'page',
: 'folder/index.mdx',
: {
: 'Hello World',
// ...
},
},
{
: 'meta',
: 'meta.json',
: {
: 'Docs',
: ['folder'],
// ...
},
},
],
};
}How is this guide?
Last updated on
