[feature] show per-document last updated time on doc pages#4004
Merged
Conversation
Show a "Last updated" date on Dev, 4.x, and community doc footers, sourced from each file's last git commit. How it works (the 2-hourly deploy uses a shallow clone, so it can't derive per-file git dates itself): - scripts/last-update/generate.js walks the full git history once and writes scripts/last-update/data.json (repo-relative path -> ISO date), covering en + zh-CN for the built versions (dev, 4.x, 3.x, 2.1) and community. - docusaurus.config.js injects it as `last_update` front matter via markdown.parseFrontMatter and enables showLastUpdateTime. Docusaurus prefers front-matter dates over git, so the deploy renders dates without calling git and without a full-history clone. - src/theme/DocItem/Footer gates display to Dev + latest stable (4.x) and community; older versions keep the data but do not show it. Refreshing the map: - .github/workflows/refresh-docs-last-update.yml (manual) regenerates from a blobless full-history checkout and opens a PR. - scripts/last-update/refresh-last-update.sh regenerates locally on macOS/Linux (yarn last-update:refresh); fails loudly on a shallow clone. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YMwVSBQkR4mbJPVbEqnCUR
scripts/last-update/data.json is an auto-generated ~1.5MB timestamp map that legitimately exceeds the size limit; skip it in check-pr-file-sizes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YMwVSBQkR4mbJPVbEqnCUR
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.
What
Adds a "Last updated" date to documentation page footers, sourced from each file's most recent git commit. Shown on Dev, 4.x (latest stable), and community docs; older versions (3.x, 2.1) intentionally don't display it (their dates would look stale).
How it works
The 2-hourly Cron Deploy uses a shallow clone, so it can't derive per-file git dates directly. Instead:
scripts/last-update/generate.jswalks the full git history in a single pass and writesscripts/last-update/data.json(repo-relative path → ISO commit date), covering en + zh-CN for the built versions (dev, 4.x, 3.x, 2.1) and community.docusaurus.config.jsloads that map and injects it aslast_updatefront matter viamarkdown.parseFrontMatter, and enablesshowLastUpdateTime. Because Docusaurus prefers front-matter dates over git, the deploy renders dates without calling git — no build-time regression, no full-history clone, and the existing deploy workflow is unchanged.src/theme/DocItem/Footergates display to Dev + latest-stable (4.x) + community.Refreshing the timestamps
.github/workflows/refresh-docs-last-update.yml). It does a blobless full-history checkout, regenerates the map, and opens a PR.yarn last-update:refresh(or./scripts/last-update/refresh-last-update.sh). Needs a full (non-shallow) clone; it fails loudly on a shallow one.Verification
Built locally (en; versions dev/4.x/2.1 + community):
Rendered dates match
git logexactly (e.g.docs/install/intro.mdx→ May 17, 2026), emitted withitemprop=dateModifiedfor SEO.🤖 Generated with Claude Code
https://claude.ai/code/session_01YMwVSBQkR4mbJPVbEqnCUR