{chart}
code
>
),
depth: 2,
url: '#hello-code',
},
];
```
# Fumadocs Core (the core library of Fumadocs): MDX Plugins
URL: /docs/headless/mdx
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/mdx/index.mdx
Useful remark & rehype plugins for your docs.
# Fumadocs Core (the core library of Fumadocs): Package Install
URL: /docs/headless/mdx/install
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/mdx/install.mdx
Generate code blocks for installing packages
console...
```
...```
...```
```
Where `./public/hello.png` points to the image in public directory.
### Example: Without Imports [#example-without-imports]
For Next.js, you can disable static imports on local images.
```ts
import { remarkImage } from 'fumadocs-core/mdx-plugins';
export default {
remarkPlugins: [[remarkImage, { useImport: false }]],
};
```
```mdx


```
Yields:
```mdx
```
### Example: Relative Paths [#example-relative-paths]
When `useImport` is enabled, you can reference local images using relative paths.
```mdx

```
Be careful that using it with `useImport` disabled **doesn't work**.
Next.js will not add the image to public assets unless you have imported it in code.
For images in public directory, you can just reference them without relative paths.
### Example: Public Directory [#example-public-directory]
Customise the path of public directory
```ts
import { remarkImage } from 'fumadocs-core/mdx-plugins';
import path from 'node:path';
export default {
remarkPlugins: [
remarkImage,
{
publicDir: path.join(process.cwd(), 'dir'),
},
],
};
```
You can pass a URL too.
```ts
import { remarkImage } from 'fumadocs-core/mdx-plugins';
export default {
remarkPlugins: [
remarkImage,
{
publicDir: 'https://my-cdn.com/images',
},
],
};
```
# Fumadocs Core (the core library of Fumadocs): Remark LLMs
URL: /docs/headless/mdx/remark-llms
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/mdx/remark-llms.mdx
Generate markdown for LLM consumption with customizable placeholders
The `remarkLLMs` plugin stringifies the processed Markdown AST to plain Markdown, the output is generated as an ESM export. This is useful for feeding content to LLMs, search indexing, or other text-based processing.
## Usage [#usage]
### Fumadocs MDX [#fumadocs-mdx]
Enable `includeProcessedMarkdown` in your collection config, Fumadocs MDX runs `remarkLLMs` internally when this is set.
```ts title="source.config.ts"
import { defineDocs } from 'fumadocs-mdx/config';
import { type LLMsOptions } from 'fumadocs-core/mdx-plugins/remark-llms';
const llmsOptions: LLMsOptions = {
// options...
};
export default defineDocs({
docs: {
postprocess: {
includeProcessedMarkdown: llmsOptions,
},
},
});
```
The stringified Markdown is exported as `_markdown` and available via `getText('processed')`, see [Collections](/docs/mdx/collections#includeprocessedmarkdown) for details.
### MDX Compiler [#mdx-compiler]
When using the MDX Compiler (or a custom pipeline), add the plugin:
```ts
import { compile } from '@mdx-js/mdx';
import { remarkLLMs, type LLMsOptions } from 'fumadocs-core/mdx-plugins/remark-llms';
const llmsOptions: LLMsOptions = {
// The output will be exported as `_markdown`
as: '_markdown',
};
const vfile = await compile('...', {
remarkPlugins: [[remarkLLMs, llmsOptions]],
});
```
## Placeholders [#placeholders]
Placeholders let you keep certain MDX components in the stringified output as special tokens instead of dropping or inlining them. That way you can:
. Rehydrate those tokens later via `renderPlaceholder()`.
. Generate a better Markdown representation with runtime data.
### Using `mdxAsPlaceholder` [#using-mdxasplaceholder]
List component names to treat as placeholders:
```ts
import { type LLMsOptions } from 'fumadocs-core/mdx-plugins/remark-llms';
const llmsOptions: LLMsOptions = {
// [!code ++]
mdxAsPlaceholder: ['Callout', 'Card'],
};
```
In the exported Markdown, `{props.children} {/* [!code highlight] */}
{props.children}
A story captures the rendered state of a UI component. It's an object with annotations that describe the component's behavior and appearance given a set of arguments.
{title}
; } ```{title}
; } ```