部署到 GitHub Pages

在线地址

本仓库默认发布到:

https://jiangfolio.github.io/light-astrodocs/

配置要点

astro.config.mjs:

export default defineConfig({
  site: 'https://jiangfolio.github.io',
  base: '/light-astrodocs',
  // ...
});
  • site:组织 / 用户的 *.github.io 根
  • base:仓库名(项目页路径前缀)
  • 站内绝对路径(如 /docs/...)经 withBase() 与 Markdown rehype 插件自动加前缀

GitHub Actions

工作流:.github/workflows/deploy.yml

  • 推送 main 或手动 workflow_dispatch 触发
  • pnpm install → 安装 Playwright Chromium(rehype-mermaid 构建渲染)→ pnpm build → 上传 dist
  • actions/deploy-pages 发布

仓库设置

  1. Settings → Pages → Build and deployment → Source 选 GitHub Actions
  2. 确保 Actions 有写 Pages 的权限(工作流已声明 pages: write)
  3. 首次推送后,在 Actions 查看 Deploy 任务;成功后打开上述在线地址

自定义域名

  1. 配置 DNS
  2. 在 public/CNAME 写入域名
  3. 将 astro.config.mjs 的 site 改为该域名,并移除 base
  4. 检查站内链接是否仍依赖旧 base 前缀

本地验证构建

pnpm build
pnpm preview

预览时同样带有 base 前缀,请访问 /light-astrodocs/。

更新日期:2026/12/06编辑此页