# Fumadocs MDX (the built-in content source): 全域選項
URL: /zh-TW/docs/mdx/global
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/mdx/global.zh-TW.mdx

自訂 Fumadocs MDX

Fumadocs MDX 的全域選項 (例如所有集合共用的 MDX 外掛) 應寫在專案根目錄的 `source.config.ts` 中。此檔案並非必要，且可搭配在 `lib/source.ts` 中透過 [Macro API](/docs/mdx/macro) 定義的集合使用。

## 全域選項 [#global-options]

```ts title="source.config.ts"
import { defineConfig } from 'fumadocs-mdx/config';

export default defineConfig({
  // 全域選項
});
```

### GlobalConfig

| Prop                      | Type                                                                             | Description                                                                                                                                                                       |
| ------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `plugins?`                | `PluginOption[] \| undefined`                                                    |                                                                                                                                                                                   |
| `compiler?`               | `"mdx" \| "satteri" \| undefined`                                                | The compiler for files compiled without a collection (e.g. `page.mdx` routes). Collections choose their own compiler via the collection-level `compiler` option. Default: `'mdx'` |
| `mdxOptions?`             | `(() => Promise<MDXPresetOptions>) \| MDXPresetOptions \| undefined`             | Configure global MDX options, used by `doc` collections with the default MDX compiler.                                                                                            |
| `satteriOptions?`         | `SatteriOptionsInput`                                                            | Configure global Sätteri options, used by `doc` collections with `compiler: "satteri"`.                                                                                           |
| `workspaces?`             | `Record<string, { dir: string; config: Record<string, unknown>; }> \| undefined` |                                                                                                                                                                                   |
| `experimentalBuildCache?` | `string \| undefined`                                                            |                                                                                                                                                                                   |

### MDX 選項 [#mdx-options]

自訂集合的[預設組合](/docs/mdx/mdx)。`mdxOptions` 適用於以 unified 編譯的集合，`satteriOptions` 則適用於設定 `compiler: 'satteri'` 的集合。

```ts tab="unified" title="source.config.ts"
import { defineConfig } from 'fumadocs-mdx/config';
import { myPlugin } from './remark-plugin';

export default defineConfig({
  mdxOptions: {
    // 需要控制順序時
    remarkPlugins: (v) => [myPlugin, ...v],
  },
});
```

```ts tab="Sätteri" title="source.config.ts"
import { defineConfig } from 'fumadocs-mdx/config';
import { myPlugin } from './mdast-plugin';

export default defineConfig({
  satteriOptions: {
    // 需要控制順序時
    mdastPlugins: (v) => [myPlugin(), ...v],
  },
});
```

或使用 minimal 預設組合：

```ts tab="unified" title="source.config.ts"
import { defineConfig } from 'fumadocs-mdx/config';

export default defineConfig({
  mdxOptions: {
    preset: 'minimal',
    // 現在只接受 MDX 處理器選項
  },
});
```

```ts tab="Sätteri" title="source.config.ts"
import { defineConfig } from 'fumadocs-mdx/config';

export default defineConfig({
  satteriOptions: {
    preset: 'minimal',
    // 此時僅接受 Sätteri 編譯選項
  },
});
```