Repository navigation
fix(sitemap): write real per-page lastmod from git history - #1341
Merged
Merged
Conversation
- last-updated: read HEAD history for .mdx (keep .md fallback, newer wins); return nothing on shallow clones instead of stamping the build commit date - sitemap-lastmod: map sitemap URLs back to source files via resolveUrl, so frontmatter slugs (how-to-parse-push.mdx -> /docs/socket/protocol/push) resolve; only docs-layout pages under /docs get lastmod, API reference, homepage and marketing pages are left without one - astro.config: sitemap serialize emits lastmod when known - release / canary workflows: fetch-depth 0 so the build has git history Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
补充一点输出格式: |
The 2026-08-17 migration commit (279e2df) renamed all 884 docs files from .md to .mdx. With --no-renames it counted as an edit of every page, so pages untouched since then got lastmod 2026-08-17 (146 en, 170 zh-CN, 170 zh-HK). Skip commits listed in IGNORED_COMMITS so those pages fall back to their pre-migration .md history, e.g. /docs/quote/pull/static now reads 2026-05-17. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
拉罐你好,谢谢审查。迁移日期的问题已改,提交 bf11a0b,麻烦有空时再构建核对一下。 改法
两种做法里选了按提交号排除,理由:
那十几个顺带改了转义的文件,内容只是 MDX 语法上的转义,没有改文字,所以也退回迁移前日期。 核对结果 仓库规定不在 AI 会话里构建,这次没有本地构建,用的是和构建同一套代码逐条计算:读
测试
构建时如果统计数字和上面对不上,麻烦在这里留言,我再查。谢谢! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
开发者平台三份网站地图(/en、/zh-CN、/zh-HK/sitemap.xml,共 1,404 个网址)都没有
<lastmod>,Google 不知道哪页改过:抽查的 6 个文档页源文件都在 Google 最近一次抓取之后改过,仍停在「已抓取未编入」。仓库里已有按提交记录取日期的代码(src/lib/last-updated.ts,页面底部 Last Updated 用),线上没生效:构建流水线fetch-depth: 1没有历史;代码只认迁移前的.md文件名。改动
src/lib/last-updated.tsHEAD历史(原来是origin/main),认.mdx,保留.md兜底、两者取较新;浅克隆时返回空,避免把构建那次提交的日期盖到每一页;加--no-renames,部分克隆下不触发拉 blobsrc/lib/sitemap-lastmod.ts(新)resolveUrl建「网址 → 源文件」对照,slug 改过网址的页面也能对上(how-to-parse-push.mdx→/docs/socket/protocol/push)。只给<locale>/docs/下 docs 布局的页面写日期;首页、sdk/pricing/skill 营销页、API Reference(/docs/api、/docs/api/*,由 openapi.yaml 生成)不写;取不到日期就不写,不用构建当天兜底astro.config.tsserialize有日期时输出lastmod.github/workflows/release.yml(3 个 job)、canary.yml、canary-cloudflare.yml、canary-aliyun.ymlfetch-depth: 0src/lib/*.test.tsbuild.yml(PR 构建检查)和autocorrect.yml保持fetch-depth: 1:不发布,网站地图日期无关紧要,也正好覆盖「没有历史时不写日期」这条路径。取舍: 全量历史而不是固定深度。固定深度(如 50)时,最老那次提交在 git 里像根提交,会把所有文件都记成那天,日期就错了;所以代码对浅克隆一律不写。仓库约 11 MB、1,107 次提交,全量拉取预计只多几秒,对构建时长影响可忽略(未在 Actions 上实测)。
顺带:页面底部「Last Updated」在线上会恢复显示(
DocMeta.astro已有逻辑,没改)。验证
按仓库 CLAUDE.md 没有在 AI 会话里跑
build:*,用下面的方式替代验证:/、/pricing、/sdk、/skill、/skill/install)/docs/cli/orders/exchange-rate→ 2026-11-09T19:04:49+08:00;/docs/screener/screener-search→ 2026-10-15T18:33:39+08:00;/docs/socket/protocol/push(源文件 how-to-parse-push.mdx)→ 2026-10-22T16:33:35+08:00。bun run test(vitest 88/88)、tsc --noEmit(仅剩一条已有的 McpToolsIsland 生成文件缺失,与本 PR 无关)、oxlint、astro sync通过。麻烦构建时看一眼
dist/en/sitemap.xml、dist/zh-CN/sitemap.xml、dist/zh-HK/sitemap.xml:文档页带<lastmod>,/docs/api/*没有,以及文档页底部出现 Last Updated。上线后验证
<lastmod>,/docs/api/*没有,没有一条等于发布当天(当天真改过的除外)。/docs/cli/orders/exchange-rate为 2026-11-09,/docs/screener/screener-search为 2026-10-15,/docs/socket/protocol/push为 2026-10-22。首屏自查
只改网站地图生成和构建流水线(构建时多读一次 git 历史),页面不加请求、不加脚本;HTML 只多一行已有的 Last Updated 文字,首屏接口和加载耗时不变。
🤖 Generated with Claude Code