---
title: 配置
description: 通过本地 adapter 文件和包 API 配置 Geistdocs 站点
type: reference
summary: 配置站点 metadata、导航、AI 功能、页面操作、翻译和本地 adapters。
prerequisites:
  - /docs/getting-started
related:
  - /docs/provider
  - /docs/env
  - /docs/versioned-docs
  - /docs/proxy
---

通过生成项目中你拥有的文件配置 Geistdocs。运行时功能来自 `@vercel/geistdocs`，本地文件控制内容、品牌、路由 adapters 和可选自定义。

## 配置文件

| File | Purpose |
| --- | --- |
| `geistdocs.tsx` | 站点级设置，包括 logo、nav、GitHub 仓库、AI prompt、翻译和功能开关。 |
| `lib/geistdocs/config.tsx` | 使用 `defineConfig` 将 `geistdocs.tsx` exports 转换为包配置。 |
| `lib/geistdocs/source.ts` | 将 Fumadocs content collections 连接到包 source adapter。 |
| `components/geistdocs/mdx-components.tsx` | 添加或覆盖 MDX 组件。 |
| `app/[lang]/docs/[[...slug]]/page.tsx` | 配置包提供的 docs page renderer。 |
| `proxy.ts` | 配置 Markdown 协商、AI-agent 重写、请求追踪和自定义 request hooks。 |
| `content/docs/meta.json` | 控制侧边栏顺序和分组标签。 |

## `geistdocs.tsx`

项目根目录下的 `geistdocs.tsx` 文件包含主要自定义选项：

```tsx title="geistdocs.tsx"
export const Logo = () => (
  <div className="flex items-center gap-2">
    <span aria-hidden className="grid size-5 place-items-center rounded bg-gray-100 text-label-12">G</span>
    <p className="font-semibold text-xl tracking-tight">Geistdocs</p>
  </div>
);

export const nav = [
  {
    label: "Docs",
    href: "/docs",
  },
];

export const suggestions = [
  "What is Vercel?",
  "What can I deploy with Vercel?",
  "What is Fluid Compute?",
  "How much does Vercel cost?",
];

export const title = "Geistdocs Documentation";

export const prompt =
  "You are a helpful assistant specializing in answering questions about Geistdocs, a modern documentation template built with Next.js and Fumadocs.";
```

## 配置选项

### `Logo`

自定义显示在站点页眉中的徽标组件：

```tsx title="geistdocs.tsx"
export const Logo = () => (
  <div className="flex items-center gap-2">
    <YourIcon className="size-5" />
    <p className="font-semibold text-xl tracking-tight">Your Brand</p>
  </div>
);
```

### `nav`

定义显示在页眉中的导航链接：

```tsx title="geistdocs.tsx"
export const nav = [
  {
    label: "Documentation",
    href: "/docs",
  },
  {
    label: "API Reference",
    href: "/api",
  },
  {
    label: "GitHub",
    href: "https://github.com/your-org/your-repo",
  },
];
```

### `suggestions`

为 AI 助手配置建议的问题：

```tsx title="geistdocs.tsx"
export const suggestions = [
  "How do I get started?",
  "What are the key features?",
  "How do I deploy my site?",
  "Where can I get help?",
];
```

每个建议可以是字符串，也可以是包含 `text` 和可选 `icon` 的对象。字符串建议不显示图标。`icon` 字段接受任何 React 元素，例如内联 SVG 组件。Ask AI 最多显示前四个不重复且非空的建议：

```tsx title="geistdocs.tsx"
const RocketIcon = () => (
  <svg aria-hidden="true" fill="none" height="16" viewBox="0 0 16 16" width="16">
    <path d="M8 1.5c2.5 1.5 3.5 4 3.5 6.5L8 12 4.5 8c0-2.5 1-5 3.5-6.5Z" stroke="currentColor" />
  </svg>
);

export const suggestions = [
  "How do I get started?",
  { text: "How do I deploy my site?", icon: <RocketIcon /> },
];
```

### `ai`

`ai` 配置还控制聊天面板及其路由：

| 选项                    | 类型                                                | 默认值        | 说明                                                                     |
| ----------------------- | --------------------------------------------------- | ------------- | ------------------------------------------------------------------------ |
| `endpoint`              | `string`                                            | `"/api/chat"` | 聊天路由的应用内路径。`basePath` 会自动添加。无效路径会抛出错误。        |
| `title`                 | `string`                                            | `"Ask AI"`    | 聊天面板的标题和无障碍标签。                                             |
| `suggestions`           | `(string \| { text: string; icon?: ReactNode })[]` | `[]`          | 建议的提示。                                                             |
| `history.retentionDays` | `number`                                            | `30`          | 对话在最近一条消息之后保留的天数。`0` 表示不保存历史，`Infinity` 表示永不过期。 |
| `messageFeedback`       | `boolean`                                           | `false`       | 在已完成的回答上显示"赞"和"踩"按钮，并将投票发送到 Geistdocs 反馈服务。 |
| `toolLabels`            | `Record<string, string>`                            | `{}`          | 指定工具运行时显示的活动标签，例如 `{ web_search: "Searching..." }`。其他工具显示 `Running <工具名>...`。 |

```tsx title="geistdocs.tsx"
export const ai = {
  endpoint: "/api/ai-chat",
  title: "Ask Acme AI",
  history: { retentionDays: 7 },
  messageFeedback: true,
};
```

详情请参阅 [向 AI 提问](/docs/ask-ai)。

### `title`

设置文档站点的主标题：

```tsx title="geistdocs.tsx"
export const title = "Your Product Documentation";
```

### `prompt`

自定义 AI 助手的系统提示，以匹配您的文档上下文：

```tsx title="geistdocs.tsx"
export const prompt =
  "You are a helpful assistant specializing in answering questions about Your Product, a platform for building amazing applications.";
```

## 高级配置

`lib/geistdocs/config.tsx` 可以添加 `content` 和 `versions` metadata，让本地 adapters 和自定义 UI 共用同一个配置对象：

```tsx title="lib/geistdocs/config.tsx"
export const config = defineConfig({
  // ...
  content: [
    { id: "docs", label: "Docs", dir: "content/docs", route: "/docs" },
    {
      id: "cookbook",
      label: "Cookbook",
      dir: "content/cookbook",
      route: "/cookbook",
    },
  ],
  versions: {
    current: "v6",
    items: [
      { id: "v6", label: "v6 latest" },
      { id: "v5", label: "v5", href: "https://v5.example.com/:path*" },
    ],
  },
});
```

阅读 [版本化文档](/docs/versioned-docs) 配置 versioned sources，阅读 [Proxy 和 Markdown 路由](/docs/proxy) 配置 route mappings。
