部署到 GitHub Pages
在线地址
本仓库默认发布到:
https://jiangfolio.github.io/light-astrodocs/
配置要点
export default defineConfig({
site: 'https://jiangfolio.github.io',
base: '/light-astrodocs',
// ...
});
site:组织 / 用户的*.github.io根base:仓库名(项目页路径前缀)- 站内绝对路径(如
/docs/...)经withBase()与 Markdownrehype插件自动加前缀
GitHub Actions
工作流:.github/workflows/deploy.yml
- 推送
main或手动workflow_dispatch触发 pnpm install→ 安装 Playwright Chromium(rehype-mermaid构建渲染)→pnpm build→ 上传distactions/deploy-pages发布
仓库设置
- Settings → Pages → Build and deployment → Source 选 GitHub Actions
- 确保 Actions 有写 Pages 的权限(工作流已声明
pages: write) - 首次推送后,在 Actions 查看 Deploy 任务;成功后打开上述在线地址
自定义域名
- 配置 DNS
- 在
public/CNAME写入域名 - 将
astro.config.mjs的site改为该域名,并移除base - 检查站内链接是否仍依赖旧
base前缀
本地验证构建
pnpm build
pnpm preview
预览时同样带有 base 前缀,请访问 /light-astrodocs/。