Remark Structure
Extract search records from your documents.
The remarkStructure plugin extracts the headings and contents of a document as records for search. Records keep the Markdown you wrote, see Stringification for how it's generated.
## Installation
Run the [command](/docs/cli) below.
<Callout>Restart the **server** after it.</Callout>
| Option | Default |
| ------ | ------- |
| `dir` | `docs` |Usage
import { defineConfig } from 'fumadocs-mdx/config';
export default defineConfig({
mdxOptions: {
// enabled by default, exported as `structuredData`
remarkStructureOptions: {},
},
});Records
Headings, paragraphs, blockquotes, tables and JSX elements are recorded (see types):
- Links are replaced by their text, images are removed.
- A table has a record per row, as a table of its header and that row. The rows share a
tablefield. - JSX elements are replaced by their content, except those kept as HTML tags by
filterElement, which search dialogs render as components. - A JSX element is a record when it has no children (see
mdxTypes), or fits on one line. - Content inside a record isn't recorded again.
By default, File, TypeTable, Callout and Card are kept as HTML tags:
import { defineConfig } from 'fumadocs-mdx/config';
export default defineConfig({
mdxOptions: {
remarkStructureOptions: {
filterElement: (node) => node.name === 'Callout' || node.name === 'Banner',
},
},
});Plugins
Nodes inserted by plugins aren't recorded, a plugin adds the records of its node with data.structuredData:
node.data = {
...node.data,
structuredData: {
// `heading` defaults to the current heading
contents: [{ heading: undefined, content: 'Generated **content**' }],
},
};To change the Markdown of authored content in records only, edit the search namespace with replaceSource().
As a Function
import { structure } from 'fumadocs-core/mdx-plugins';
import remarkMath from 'remark-math';
// with the remark plugins your content needs
const data = structure(content, [remarkMath], options);Options
Prop
Type
How is this guide?
Last updated on
