This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
部署到 Cloudflare Pages
1. 连接仓库
Cloudflare Dashboard → Workers & Pages → Create → Pages → Connect to Git → 选择模板仓库。
2. 构建配置
配置项
值
Framework preset
None(或 Astro)
Build command
npm run build
Build output directory
dist
环境变量
NODE_VERSION = 22.12.0
3. Pages Functions
functions/ 目录会被自动部署为 Pages Functions,无需额外配置:
POST /api/submit —— 投稿 → GitHub PR(需配置 CMS-Bot )
GET/POST /api/messages —— 留言墙(需绑定 D1,见 Message-Board )
4. 环境变量总表
在 Pages 项目 → Settings → Variables and Secrets 中配置(Production 与 Preview 都要):
变量
必填
用途
NODE_VERSION
✓
22.12.0
GITHUB_APP_ID
✓*
cms-bot 的 App ID( *启用投稿功能需要)
GITHUB_INSTALLATION_ID
✓*
cms-bot 的 Installation ID
GITHUB_PRIVATE_KEY
✓*
cms-bot 的 .pem 私钥全文
GITHUB_OWNER
✓*
仓库所有者
GITHUB_REPO
✓*
仓库名
GITHUB_BASE_BRANCH
投稿目标分支,默认 main
CONTENT_DIR
文章目录,默认 src/content
MEDIA_DIR
上传文件目录,默认 public/pages/static
MEDIA_URL_PREFIX
上传文件 URL 前缀,默认 /pages/static
SONGS_DIR
歌曲目录,默认 src/songs
TURNSTILE_SECRET_KEY
Turnstile 私钥,见 Turnstile
PUBLIC_TURNSTILE_SITE_KEY
Turnstile 站点 key( 构建时 变量,需加入构建环境)
不配置 GitHub 相关变量时:站点正常浏览,仅投稿功能不可用。
5. 后续更新
合并任何投稿 PR 或直接 push 到默认分支后,Pages 会自动重新构建部署,内容随即上线。