Skip to content

Commit 3f8caf0

Browse files
committed
添加快速开始文档,指导用户创建第一个 ObjectDocs 文档站点
1 parent c3c0e1b commit 3f8caf0

File tree

1 file changed

+116
-0
lines changed

1 file changed

+116
-0
lines changed

content/docs/getting-started.mdx

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
title: 快速开始
3+
description: 在几分钟内创建您的第一个 ObjectDocs 文档站点。
4+
---
5+
6+
# 快速开始
7+
8+
ObjectDocs 是一个基于 Next.js 14 和 Fumadocs 的现代文档引擎,支持“配置即代码”的理念。本指南将帮助你快速搭建一个新的文档项目。
9+
10+
## 准备工作
11+
12+
确保你的环境满足以下要求:
13+
14+
- **Node.js**: 18.17 或更高版本
15+
- **包管理器**: 推荐使用 pnpm (npm 或 yarn 也可以)
16+
17+
## 1. 创建新项目
18+
19+
我们提供了一个 CLI 工具来快速初始化项目。在你的终端中运行:
20+
21+
<Steps>
22+
### 初始化目录结构
23+
24+
在你的项目根目录下,创建以下文件结构:
25+
26+
```bash
27+
mkdir -p content/docs
28+
```
29+
30+
### 安装依赖
31+
32+
安装 `@objectdocs/cli` 作为开发依赖:
33+
34+
```bash title="Terminal"
35+
pnpm add -D @objectdocs/cli
36+
```
37+
38+
### 配置启动脚本
39+
40+
`package.json` 中添加以下脚本:
41+
42+
```json title="package.json"
43+
{
44+
"scripts": {
45+
"dev": "objectdocs dev",
46+
"build": "objectdocs build",
47+
"start": "objectdocs start"
48+
}
49+
}
50+
```
51+
</Steps>
52+
53+
## 2. 添加内容
54+
55+
ObjectDocs 使用文件系统路由。所有的文档都存放在 `content/docs` 目录下。
56+
57+
<Steps>
58+
### 创建首页
59+
60+
新建 `content/docs/index.mdx`
61+
62+
```mdx title="content/docs/index.mdx"
63+
---
64+
title: 欢迎
65+
description: 你的新文档站点
66+
---
67+
68+
# Hello World
69+
70+
欢迎使用 ObjectDocs!这是你的首页。
71+
```
72+
73+
### 配置侧边栏
74+
75+
新建 `content/docs/meta.json` 来定义页面顺序:
76+
77+
```json title="content/docs/meta.json"
78+
{
79+
"pages": ["index"]
80+
}
81+
```
82+
83+
### 配置站点信息
84+
85+
新建 `content/docs.site.json` 来配置站点名称和导航:
86+
87+
```json title="content/docs.site.json"
88+
{
89+
"branding": {
90+
"name": "My Docs"
91+
},
92+
"links": [
93+
{
94+
"text": "Home",
95+
"url": "/"
96+
}
97+
]
98+
}
99+
```
100+
</Steps>
101+
102+
## 3. 启动开发服务器
103+
104+
运行以下命令启动服务:
105+
106+
```bash title="Terminal"
107+
pnpm dev
108+
```
109+
110+
现在访问 [http://localhost:7777](http://localhost:7777),你应该能看到你的文档站点了!
111+
112+
## 下一步
113+
114+
- [配置文件](./configuration) - 了解更多配置选项
115+
- [编写内容](./writing) - 学习 MDX 语法和组件使用
116+
- [部署](./deployment) - 将你的文档发布到生产环境

0 commit comments

Comments
 (0)