# 配置

## `minidocs(options?)`

Astro integration，从 `@minidocs/astro` 默认导入，加在 `astro.config.mjs` 的 `integrations` 里。

| 选项                    | 类型                                   | 默认值    | 作用                                                 |
| --------------------- | ------------------------------------ | ------ | -------------------------------------------------- |
| `fallback`            | `Record<string, string \| string[]>` | `{}`   | 页面没有翻译时依次尝试的语言，比如 `{ en: 'zh' }`。需要 Astro 的 `i18n` |
| `markdown.directives` | `boolean`                            | `true` | 是否支持 `:::tip[标题]` 提示框                              |
| `markdown.alerts`     | `boolean`                            | `true` | 是否支持 GitHub 的 `> [!TIP]` 提示框                       |

minidocs 还会读取 Astro 配置里的这些项：

| Astro 配置                              | 影响                                     |
| ------------------------------------- | -------------------------------------- |
| `i18n.locales`、`i18n.defaultLocale`   | 内容的语言目录和地址里的语言段。`locales` 只能是字符串       |
| `i18n.routing.prefixDefaultLocale`    | 默认语言的地址是否带语言段                          |
| `base`、`trailingSlash`、`build.format` | 链接的前缀和末尾斜杠                             |
| `site`                                | llms.txt 和 llms-full.txt 里的链接写成完整的 URL |

不支持 `i18n.routing: 'manual'` 和 Astro 的 `i18n.fallback`，设置了会报错。

## `glob(options)`

从 `@minidocs/astro/loaders` 导入。它是 Astro 的 `glob` loader，接受 Astro `glob` 的所有选项，另外有：

| 选项       | 类型                   | 默认值   | 作用                                                                           |
| -------- | -------------------- | ----- | ---------------------------------------------------------------------------- |
| `prefix` | `string`             | 站点根路径 | 页面所在的路径，比如 `docs` 表示页面在 `/docs/` 下                                           |
| `filter` | `(entry) => boolean` |       | 返回 `false` 的条目不会进入集合。`entry` 有 `id`、`data` 和 `filePath`，`data` 已经过 schema 校验 |

集合的 schema 里要有 `title: string`，它是页面在侧边栏和 llms.txt 里的标题。

用它加载的集合会生成页面 id 的类型，正文里的文件链接可以指向它，`listPages`、`toHref`、`toMarkdown` 也都可以用于它。两个集合的页面地址相同时，同步内容时会报错。
