---
title: "编写文档"
description: "创建 MDX 页面，设置导航顺序，并使用内置的文档组件。"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.microcharon.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# 编写文档

## 创建一个页面 {#create}

在 `src/content/docs/` 下创建 `.mdx` 文件。例如，`guides/first-page.mdx` 对应 `/guides/first-page/`。文件开头通过 frontmatter 填写页面标题和摘要。

```md title="src/content/docs/guides/first-page.mdx"
---
title: 我的第一篇文档
description: 这篇文档涵盖的内容。
sidebar:
  order: 30
---

## 第一节

从读者需要完成的任务写起。
```

## 整理侧栏 {#navigation}

每个章节的 `index.mdx` 是该章节的入口。以 `sidebar.group.label` 设置分组名称，以 `sidebar.order` 调整组内顺序。可在 [配置参考](https://docs.microcharon.dev/reference/) 查到侧栏入口文件。

## 添加示例和提示 {#examples}

为代码围栏指定语言，站点会显示语法高亮和复制按钮。重要信息可以用 `Aside` 组件。

> **手动设置锚点**
>
> 为需要长期引用的小节加一个明确的锚点，例如 `{ "#navigation" }`。这样改标题时，外部链接仍能定位。

提交前运行 `pnpm build`，检查页面和站内链接。

Source: https://docs.microcharon.dev/guides/writing/index.mdx
