Skip to content

Rebase 到 astro-paper v6.1(Astro 6 + 纯静态 Cloudflare Pages + 双语) - #4

Merged
t0saki merged 8 commits into
mainfrom
rebase/v6.1
Jun 9, 2026
Merged

t0saki merged 8 commits into
mainfrom
rebase/v6.1

Conversation

@t0saki

@t0saki t0saki commented Jun 9, 2026

Copy link
Copy Markdown
Owner

将项目从 Astro 5.16 全量 rebase 到上游 astro-paper v6.1(Astro 6.4 / Tailwind 4.3),保留全部双语能力,改为纯静态构建部署到 Cloudflare Pages。

关键决策(过程中确认)

  • v6.1 的"原生 i18n"只是 UI 文案翻译层,没有多语言路由;本项目的双语能力更强,故为"在 v6.1 引擎上重建双语"。
  • @astrojs/cloudflare v13 放弃 Pages、只支持 Workers,且其 Astro 6 的 workerd 预渲染当前无法静态构建(withastro/astro#15684、#15650)→ 主分支改为纯静态留在 Pages;Keystatic/Workers 版保留在 keystatic-workers 分支。

主要变更

  • 依赖:astro ^6.4、tailwind ^4.3、ts ^6、eslint ^10;新增 mdx / rehype-callouts / slugify。
  • 配置架构:采用上游 astro-paper.config.ts + src/config.ts resolver + src/types/config.ts。
  • 内容迁移:src/data/blog/ → src/content/posts/{zh,en},集合 blog → posts。
  • i18n:上游 typed UIStrings + 新增中文 lang/zh.ts;getPostPaths 从 slug 剥离语言目录、按目录推断语言。
  • 路由:根树(zh)按 zh/ 过滤;新建 src/pages/[lang]/** 英文树(按 en/ 过滤);LanguageSwitcher + Layout 语言重定向脚本;分语言 RSS;_redirects 处理历史 /zh/*。
  • 字体:恢复中文字体(@chinese-fonts/sypxzs 思源屏显臻宋)。
  • 动态 OG:satori + sharp,在纯静态 Node 构建下生成(双树路由)。

验证

  • pnpm build 全绿:astro check 0 错误、19 页、pagefind 索引 zh/en。
  • astro preview 实跑:16 个关键路由全部 200(中/英首页、文章、标签、归档、关于、搜索、两个 RSS、3 个 OG 图)。
  • eslint 通过、prettier --check 全部符合。

部署须知

  • Cloudflare Pages 构建命令设为 pnpm build;Node 已由 .nvmrc 固定到 22.12。
  • 旧 Pages 项目可继续使用(纯静态,无需迁 Workers)。

已知限制(README 已注明)

  • 中文标题的 OG 图仍为 tofu(fork 原有限制,satori 缺 CJK 字体)——功能未回退,后续可加 CJK 字体彻底修复。
  • keystatic-workers 分支需等上游 Cloudflare 适配器修复后才能构建/部署。

🤖 Generated with Claude Code

t0saki and others added 8 commits June 9, 2026 23:07
- astro ^6.4.2, tailwind ^4.3, ts ^6, eslint ^10
- add @astrojs/mdx, rehype-callouts, slugify (v6.1 features)
- fork deps on Astro 6: @astrojs/cloudflare ^13.7, @astrojs/react ^5, @keystatic/astro ^5.1, wrangler ^4.83
- adopt upstream eslint.config.js / .prettierrc / .prettierignore
- merge tsconfig (react jsx + @/astro-paper.config path)
- pnpm-workspace allowBuilds for sharp/resvg/workerd/esbuild

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…orkers variant)

Adopts upstream v6.1 config architecture (astro-paper.config.ts + src/config.ts
resolver + src/types/config.ts) with bilingual i18n (zh default at /, en at /en/),
content moved to src/content/posts/{zh,en}, Keystatic paths + repo updated, and
the Cloudflare Workers adapter (wrangler.jsonc rewritten for Workers Static Assets).

NOTE: this commit preserves the Keystatic + Cloudflare adapter setup for the
`keystatic-workers` compatibility branch. The Astro 6 Cloudflare adapter currently
fails static prerendering in the workerd runtime (withastro/astro#15684, #15650),
so main switches to a pure-static build for Cloudflare Pages in the next commit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Drop Cloudflare Workers adapter + Keystatic + React (preserved on
  keystatic-workers branch) due to Astro 6 adapter prerender bug.
- Pure-static build via Node prerender: astro check + build + pagefind all green.
- Content lives in src/content/posts/{zh,en}; collections sync; 13 pages build.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ng helpers

- src/i18n/lang/zh.ts: full Chinese translation of the UIStrings interface
- src/i18n/helpers.ts: LOCALES list + getAlternatePath for the language switcher

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- getPostPaths: strip locale dir from slug, derive locale from post dir
- Root pages filter zh posts; English [lang]/ tree mirrors them (filters en)
- LanguageSwitcher in Header (upstream Header already locale-aware)
- Layout: loop-safe preferred-lang/browser-lang redirect script
- About content split into pages/{zh,en}/about.md
- Per-language RSS (/rss.xml zh, /en/rss.xml en); _redirects for legacy /zh/*
- astro check: 0 errors; build emits both /posts/welcome and /en/posts/welcome

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ploy

- Re-enable dynamic OG images (satori + sharp) — works in the pure-static Node
  build; dual-tree routes (/posts/.../index.png zh, /en/posts/.../index.png en).
  CJK titles still fall back to the satori font set (pre-existing fork limitation).
- Restore CJK body font: @chinese-fonts/sypxzs (Source Han Serif) + --font-app stack.
- Cloudflare Pages deploy: _redirects (legacy /zh/* -> /*) copied into dist via
  the build script (placing it in public/ breaks the Vite build).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Update README.md / README-en.md for the v6.1 pure-static Cloudflare Pages setup
- Add Branches section (main vs keystatic-workers) and a simple upstream-upgrade
  git flow (git fetch/merge upstream) + list of fork-specific files
- Document the v6.1 rebase changes
- prettier format pass (all files clean)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Astro 6 requires Node >=22.12; Cloudflare Pages defaults to an older Node
unless told otherwise.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@t0saki
t0saki merged commit 30a838f into main Jun 9, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant