如何添加文章
本指南介绍如何向 Industrial Docs 文档中心添加新文章。
src/content/docs/├── index.mdx # 首页├── guides/ # 指南目录│ └── getting-started.md├── best-practices/ # 最佳实践目录│ └── getting-started.md└── zh-cn/ # 中文版本 ├── index.mdx ├── guides/ └── best-practices/添加新文章的步骤
Section titled “添加新文章的步骤”1. 创建 Markdown 文件
Section titled “1. 创建 Markdown 文件”在适当的目录中创建新的 .md 或 .mdx 文件。
# 示例:创建新的指南文章touch src/content/docs/guides/my-new-article.md2. 编写 Frontmatter
Section titled “2. 编写 Frontmatter”每个文档文件顶部都需要 frontmatter:
---title: 文章标题description: 文章描述(显示在搜索结果中)---3. 编写内容
Section titled “3. 编写内容”使用 Markdown 语法编写文档内容。
## 标题
这是正文内容。
### 子标题
- 列表项 1- 列表项 24. 添加中文版本
Section titled “4. 添加中文版本”在 zh-cn 目录中创建对应的中文文章:
# 示例:为新文章创建中文版本touch src/content/docs/zh-cn/guides/my-new-article.md运行构建命令进行验证:
npm run buildStarlight 组件
Section titled “Starlight 组件”您可以使用 Starlight 的内置组件来增强文档效果:
:::tip这是一个提示:::
:::note这是一个注意事项:::
:::caution这是一个警告:::\`\`\`javascriptconsole.log('Hello World');\`\`\`import { Card, CardGrid } from '@astrojs/starlight/components';
<CardGrid> <Card title="标题">内容</Card></CardGrid>- 文件名中使用连字符
-分隔单词 - frontmatter 中的
title和description是必填项 - 建议为每篇中文文章创建英文版本
- 保持中文和英文文章之间的路径一致