Skip to content

Commit f3951d4

Browse files
Add comprehensive deployment documentation for VitePress GitHub Pages setup
Co-authored-by: GreenShadeZhang <[email protected]>
1 parent d7f1e24 commit f3951d4

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

docs-website/DEPLOYMENT.md

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# VitePress 文档部署指南
2+
3+
本文档说明如何将 VitePress 文档网站部署到 GitHub Pages。
4+
5+
## 🚀 自动部署设置
6+
7+
### 1. GitHub Pages 配置
8+
9+
1. 进入 GitHub 仓库设置页面
10+
2. 点击左侧菜单中的 **Pages**
11+
3.**Source** 部分选择 **GitHub Actions**
12+
4. 保存设置
13+
14+
### 2. 自定义域名(可选)
15+
16+
如果您已经配置了自定义域名:
17+
18+
1. **修改 GitHub Actions 工作流**
19+
编辑 `.github/workflows/deploy-docs.yml` 文件:
20+
```yaml
21+
- name: Build with VitePress
22+
run: npm run build
23+
working-directory: docs-website
24+
env:
25+
CUSTOM_DOMAIN: true # 取消注释这一行
26+
27+
- name: Add CNAME file (if using custom domain)
28+
run: |
29+
echo "your-domain.com" > docs-website-dist/CNAME # 修改为您的域名
30+
if: true # 将 false 改为 true
31+
```
32+
33+
2. **GitHub Pages 设置**:
34+
- 在 GitHub 仓库的 Pages 设置中,在 **Custom domain** 字段输入您的域名
35+
- 建议启用 **Enforce HTTPS**
36+
37+
### 3. 触发部署
38+
39+
部署将在以下情况自动触发:
40+
- 向 `main` 分支推送包含 `docs-website/` 目录更改的提交
41+
- 手动在 GitHub Actions 页面运行 "Deploy Documentation to GitHub Pages" 工作流
42+
43+
## 🔧 本地开发
44+
45+
```bash
46+
# 进入文档目录
47+
cd docs-website
48+
49+
# 安装依赖
50+
npm install
51+
52+
# 启动开发服务器
53+
npm run dev
54+
55+
# 构建生产版本
56+
npm run build
57+
58+
# 预览构建结果
59+
npm run preview
60+
```
61+
62+
## 📁 目录结构
63+
64+
```
65+
docs-website/
66+
├── .vitepress/
67+
│ └── config.ts # VitePress 配置文件
68+
├── zh/ # 中文文档
69+
├── en/ # 英文文档
70+
├── public/ # 静态资源
71+
├── package.json # 项目配置
72+
└── README.md # 说明文档
73+
```
74+
75+
## 🌐 访问地址
76+
77+
部署成功后,文档网站将可通过以下地址访问:
78+
79+
- **使用默认 GitHub Pages 域名**:`https://maker-community.github.io/Verdure.Assistant/`
80+
- **使用自定义域名**:`https://your-domain.com/`
81+
82+
## 🐛 故障排除
83+
84+
### 部署失败
85+
86+
1. **检查工作流权限**:
87+
- 确保仓库的 Actions 权限设置正确
88+
- 检查 `GITHUB_TOKEN` 是否有足够权限
89+
90+
2. **检查依赖问题**:
91+
```bash
92+
cd docs-website
93+
npm ci # 重新安装依赖
94+
npm run build # 本地测试构建
95+
```
96+
97+
3. **检查配置文件**
98+
- 验证 `.vitepress/config.ts` 语法正确
99+
- 确保 `base` 路径配置正确
100+
101+
### 页面显示问题
102+
103+
1. **样式或资源加载失败**
104+
- 检查 `base` 配置是否与实际部署路径匹配
105+
- 如果使用自定义域名,确保 `CUSTOM_DOMAIN` 环境变量设置正确
106+
107+
2. **404 错误**
108+
- 检查路由配置
109+
- 确保所有引用的文件都存在
110+
111+
### 多语言问题
112+
113+
1. **语言切换不正常**
114+
- 检查 `locales` 配置
115+
- 确保对应语言的文件都存在
116+
117+
## 📋 部署检查清单
118+
119+
- [ ] GitHub Pages 设置为 "GitHub Actions"
120+
- [ ] 工作流权限配置正确
121+
- [ ] 如果使用自定义域名,已修改工作流配置
122+
- [ ] 本地构建测试通过
123+
- [ ] 推送更改到 main 分支
124+
- [ ] 检查 Actions 运行状态
125+
- [ ] 验证部署后的网站访问正常
126+
127+
## 📖 相关文档
128+
129+
- [VitePress 官方文档](https://vitepress.dev/)
130+
- [GitHub Pages 文档](https://docs.github.com/pages)
131+
- [GitHub Actions 文档](https://docs.github.com/actions)

docs-website/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ npm run preview
6565

6666
构建结果在 `docs-website-dist/` 目录中
6767

68+
## 🚀 部署
69+
70+
### GitHub Pages 自动部署
71+
72+
项目已配置 GitHub Actions 自动部署到 GitHub Pages:
73+
74+
1. **自动触发**:向 `main` 分支推送 `docs-website/` 目录的更改
75+
2. **手动运行**:在 GitHub Actions 页面手动触发
76+
3. **部署地址**https://maker-community.github.io/Verdure.Assistant/
77+
78+
详细部署配置请参考 [DEPLOYMENT.md](./DEPLOYMENT.md)
79+
6880
## 📝 内容概览
6981

7082
### 入门指南 (Guide)

0 commit comments

Comments
 (0)