Fumadocs

Remark Include

Reuse content from other files.

Usage

Fumadocs MDX and Local Markdown enable it by default, see Include for the syntax.

For other compilers, add it to your Remark plugins. Paths are relative to the compiled file, so pass a file with its path:

MDX Compiler
import { compile } from '@mdx-js/mdx';
import { VFile } from 'vfile';
import { remarkInclude } from 'fumadocs-core/mdx-plugins';

await compile(new VFile({ path: 'content/page.mdx', value: '...' }), {
  remarkPlugins: [remarkInclude],
});

Included Markdown & MDX files are parsed by the current processor, pass getProcessor to parse them by their own format instead:

import { createProcessor } from '@mdx-js/mdx';

const processors = {
  md: createProcessor({ format: 'md' }),
  mdx: createProcessor({ format: 'mdx' }),
};

await compile(file, {
  remarkPlugins: [[remarkInclude, { getProcessor: (format) => processors[format] }]],
});

Prop

Type

How is this guide?

Last updated on