Configuration
Learn to configure Fumadocs MDX
Configuration File
Configure Fumadocs MDX by creating a source.config.ts
file.
Global Options
Shared options of Fumadocs MDX.
Prop | Type | Default |
---|---|---|
mdxOptions | DefaultMDXOptions | - |
lastModifiedTime | "git" | "none" | 'none' |
generateManifest | boolean | false |
MDX Options
Customise the default MDX options of all MDX files.
See Default MDX Options for more details.
Manifest
Enable the generateManifest
option to generate a manifest file for production builds.
See Manifest to learn more.
Collections
Define a collection to parse a certain set of files.
Prop | Type | Default |
---|---|---|
dir | string | string[] | - |
files | string[] | - |
schema | Schema | ((ctx: TransformContext) => Schema) | - |
type | Type | - |
transform | (entry: CollectionEntry<Type, output<Schema>>, globalConfig?: GlobalConfig | undefined) => Output | Promise<Output> | - |
mdxOptions | Type extends "doc" ? MDXOptions : never | - |
dir
Directories to scan input files.
Schema
The Zod schema to validate file data (frontmatter on doc
type, content on meta
type).
You can add additional properties to the output. Note that the validation is done by build time, hence the output must be serializable.
You can also pass a function and receives the transform context.
Type
The accepted type of collection.
Type | Description |
---|---|
meta | JSON/YAML File |
doc | Markdown/MDX Documents |
MDX Options
You can also customise MDX options from collections.
Notice that passing mdxOptions
to collection overrides all defaults from global config.
We use getDefaultMDXOptions
to apply default MDX options, it accepts the Default MDX Options.
For full control over MDX options, you can pass MDX options without getDefaultMDXOptions
, which means no defaults will be applied (except the ones from MDX.js).
This API only available on doc
type.
Transform
A function to perform runtime transformation on collection entries.
See Transform.
Define Docs
You can use defineDocs
to define the required collections to work with Fumadocs.
It offers the same API as defineCollections
.
Extend schema
You can extend the default Zod schema of docs
and meta
.
Default MDX Options
Fumadocs MDX uses the MDX Compiler to compile MDX files into JavaScript files.
Since some options should be applied by default, it exposes a getDefaultMDXOptions
function that applies these defaults on the input MDX options.
To allow changing the default settings, it supports a different set of options.
MDX options from global config are always applied automatically.
Remark Plugins
These plugins are applied by default:
- Remark Image - Handle images
- Remark Heading - Extract table of contents
- Remark Structure - Generate search indexes
- Remark Exports - Exports the output generated by remark plugins above
You can add other remark plugins with:
You can also pass a function to control the order of remark plugins.
Rehype Plugins
These plugins are applied by default:
- Rehype Code - Syntax highlighting
Same as remark plugins, you can pass an array or a function to add other rehype plugins.
Customise Built-in Plugins
Customise the options of built-in plugins.
Export Properties from vfile.data
Some remark plugins store their output in vfile.data
(an compile-time memory) which cannot be accessed from your code.
Fumadocs MDX applies a remark plugin that turns vfile.data
properties into exports, so that you can access these properties when importing the MDX file.
You can define additional properties to be exported.
By default, it includes:
toc
for the Remark Heading pluginstructuredData
for the Remark Structure Pluginfrontmatter
for the frontmatter of MDX (usinggray-matter
)
Plugin Options
Fumadocs MDX offers loaders and a Fumadocs Source API adapter to integrate with Fumadocs.
You can configure the plugin by passing options to createMDX
in next.config.mjs
.
Config Path
Customise the path of config file.
Last updated on