主题
部署到 Cloudflare Pages
1. 本地构建
bash
npm install
npm run convert
npm run download-images
npm run optimize-images
npm run validate
npm run build构建产物位于 docs/.vitepress/dist。
2. 上传到 Git 仓库
将整个 javaguide-site 目录提交到 GitHub 或 GitLab 仓库。不要提交 node_modules。
3. 连接 Cloudflare Pages
- 登录 Cloudflare Dashboard。
- 进入
Workers & Pages。 - 选择
Create application→Pages→Connect to Git。 - 选择仓库。
- 配置构建参数:
- Framework preset:
VitePress - Build command:
npm run build - Build output directory:
docs/.vitepress/dist - Node version:
22或24
- Framework preset:
- 点击部署。
部署成功后会得到一个 *.pages.dev 地址。
4. 绑定自定义域名
- 在 Pages 项目中选择
Custom domains。 - 添加你的域名或子域名。
- 按 Cloudflare 提示配置 DNS。
5. 更新内容
后续更新流程:
bash
npm run convert
npm run download-images
npm run optimize-images
npm run validate
npm run build
git add .
git commit -m "update docs"
git pushCloudflare Pages 会自动重新构建和发布。