toMedia
框架集成运行时加载器

Bun

Fumadocs MDX 的 Bun 运行时加载器

Bun 加载器通过内置的内容源插件,在 Bun 环境中提供对 MDX 和 meta 文件的运行时访问。

安装与配置

bunfig.toml

bunfig.toml
preload = ["./scripts/preload.ts"]

插件初始化

scripts/preload.ts
import { createMdxPlugin } from 'fumadocs-mdx/bun';

Bun.plugin(createMdxPlugin());

注册后,该插件将添加对运行时加载 MDX/meta 文件的支持,允许在使用 Bun 执行脚本时直接访问内容文件。

重新生成 Source 文件夹(可选)

.source 目录缺失或使用 Vite(默认为 Vite 特定 API)时,可以重新生成:

Next.js 方式:

import { postInstall } from 'fumadocs-mdx/next';
await postInstall({ configPath: 'source.config.ts' });

Vite 方式:

import { postInstall } from 'fumadocs-mdx/vite';
await postInstall({
  configPath: 'source.config.ts',
  index: { target: 'bun' },
});

On this page