Skip to content

[feature] show per-document last updated time on doc pages#4004

Merged
morningman merged 2 commits into
apache:masterfrom
morningman:feat/docs-last-update-time
Jul 22, 2026
Merged

[feature] show per-document last updated time on doc pages#4004
morningman merged 2 commits into
apache:masterfrom
morningman:feat/docs-last-update-time

Conversation

@morningman

Copy link
Copy Markdown
Contributor

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:

  1. scripts/last-update/generate.js walks the full git history in a single pass and writes scripts/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.
  2. docusaurus.config.js loads that map and injects it as last_update front matter via markdown.parseFrontMatter, and enables showLastUpdateTime. 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.
  3. src/theme/DocItem/Footer gates display to Dev + latest-stable (4.x) + community.

Refreshing the timestamps

  • Manually via GitHub Actions: run the Refresh Docs Last-Update Map workflow (.github/workflows/refresh-docs-last-update.yml). It does a blobless full-history checkout, regenerates the map, and opens a PR.
    • ⚠️ Requires the repo/org setting "Allow GitHub Actions to create and approve pull requests" to be enabled.
  • Locally (macOS/Linux): 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):

Area Pages showing "Last updated"
Dev 1588
4.x 1586
community 47
2.1 0 (correctly gated off)

Rendered dates match git log exactly (e.g. docs/install/intro.mdx → May 17, 2026), emitted with itemprop=dateModified for SEO.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YMwVSBQkR4mbJPVbEqnCUR

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
@morningman
morningman merged commit 9b14603 into apache:master Jul 22, 2026
3 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