Feat: Enable per-page git timestamps for sitemap lastmod and footer updates#298
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe documentation build now attempts to fetch complete Git history before running VitePress, and VitePress enables per-page last-updated timestamps in its SEO configuration. ChangesVitePress build metadata
Estimated code review effort: 2 (Simple) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Line 8: Update the package.json build script to avoid silently continuing
after a failed git unshallow fetch: either propagate the fetch failure so the
build stops with shallow history, or explicitly disable VitePress lastUpdated
and sitemap lastmod values when the fallback is used.
- Line 8: Update the package.json build script’s failed git fetch fallback to
use a Node-based no-op command instead of `true`, ensuring the subsequent
`vitepress build docs` runs consistently across Windows and Unix shells.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5e093210-d1fd-4dbd-adb9-8a5946b11351
📒 Files selected for processing (2)
docs/.vitepress/config.mtspackage.json
| "scripts": { | ||
| "dev": "vitepress dev docs", | ||
| "build": "vitepress build docs", | ||
| "build": "(git fetch --unshallow || true) && vitepress build docs", |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n## package.json\n'
cat -n package.json | sed -n '1,120p'
printf '\n## docs/.vitepress/config.mts\n'
cat -n docs/.vitepress/config.mts | sed -n '1,260p'
printf '\n## Search for lastmod / git history references\n'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' 'lastmod|git fetch --unshallow|unshallow|git history|last-modified|lastModified' .Repository: makeplane/developer-docs
Length of output: 15537
🌐 Web query:
VitePress lastUpdated sitemap git history shallow clone build behavior
💡 Result:
In VitePress, the lastUpdated feature and sitemap generation rely on Git commit history to determine the timestamp of files [1][2]. When a build environment performs a shallow clone (which is the default in many CI/CD services like GitHub Actions, Netlify, or Cloudflare Pages), only the most recent commit is typically available [3][4][1]. Impact of Shallow Clone: Because VitePress internally executes git log -1 --pretty="%at" on each file to retrieve its timestamp [1][5], a shallow clone limits the history available to Git [3][1]. Consequently, if the history is insufficient to identify the actual last modification commit for each individual file, many or all pages may incorrectly display the same timestamp (often the date of the most recent commit in the repository) [3][4][1]. Resolution for CI/CD Builds: To ensure accurate timestamps for lastUpdated and sitemap generation, you must configure your CI/CD environment to fetch the full Git history: 1. GitHub Actions: Update your checkout step to include fetch-depth: 0 [1][6]. - name: Checkout uses: actions/checkout@v5 with: fetch-depth: 0 2. Other CI/CD Environments: If your provider does not support configuring the clone depth, you can prepend the build command in your package.json with a manual fetch to unshallow the repository [4][1]: "docs:build": "git fetch --unshallow && vitepress build docs" Sitemap Behavior: VitePress uses the lastUpdated timestamp for the sitemap's lastmod attribute [7][2]. As of recent updates, VitePress respects any custom lastUpdated value defined in a file's frontmatter; if that is absent, it falls back to the timestamp retrieved from the Git log [8][2][9]. Ensuring a full Git history as described above is necessary for the sitemap's lastmod values to reflect the true historical modification dates of your files [1][2].
Citations:
- 1: https://github.com/vuejs/vitepress/blob/main/docs/en/reference/default-theme-last-updated.md
- 2: https://github.com/vuejs/vitepress/blob/9a2d1651/src/node/build/generateSitemap.ts
- 3: https://vitepress.dev/reference/default-theme-last-updated
- 4: lastUpdated same date display on cloudflare pages vuejs/vitepress#3580
- 5: https://github.com/vuejs/vitepress/blob/9a2d1651/src/node/utils/getGitTimestamp.ts
- 6: LastupDateTime does not work correctly vuejs/vitepress#4139
- 7: https://vitepress.dev/guide/sitemap-generation
- 8: Last Updated Time in sitemap.xml vuejs/vitepress#3931
- 9: vuejs/vitepress@7fcf462
Don’t ignore a failed unshallow fetch at package.json:8 — || true leaves the build running with shallow history, so VitePress can publish incorrect lastUpdated/sitemap lastmod values. Make the build fail if history stays shallow, or explicitly disable those timestamps in that fallback path.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@package.json` at line 8, Update the package.json build script to avoid
silently continuing after a failed git unshallow fetch: either propagate the
fetch failure so the build stops with shallow history, or explicitly disable
VitePress lastUpdated and sitemap lastmod values when the fallback is used.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '--- package.json ---\n'
cat -n package.json | sed -n '1,80p'
printf '\n--- search for build script usage / Windows hints ---\n'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' --glob '!coverage' '"build"|vitepress build docs|git fetch --unshallow|cmd\.exe|Windows|cross-platform' .
printf '\n--- git-related package manager hints ---\n'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' --glob '!coverage' '^packageManager|engines|scripts' package.json .npmrc .yarnrc* .pnpmfile* 2>/dev/null || trueRepository: makeplane/developer-docs
Length of output: 253
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- package.json ---'
cat -n package.json | sed -n '1,120p'
echo
echo '--- search for build script usage / Windows hints ---'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' --glob '!coverage' '"build"|vitepress build docs|git fetch --unshallow|cmd\.exe|Windows|cross-platform' .
echo
echo '--- git-related package manager hints ---'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' --glob '!coverage' '^packageManager|engines|scripts' package.json .npmrc .yarnrc* .pnpmfile* 2>/dev/null || trueRepository: makeplane/developer-docs
Length of output: 4342
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- top-level files ---'
git ls-files | sed -n '1,120p'
echo
echo '--- README / docs mentioning setup or supported OS ---'
rg -n --hidden --glob '!node_modules' --glob '!dist' --glob '!build' --glob '!coverage' -i 'windows|wsl|git bash|macos|linux|install|setup|pnpm|npm run build|package manager|prerequisite|supported os' README* docs package.json .github 2>/dev/null || true
echo
echo '--- package manager docs in root ---'
fd -a 'README*|CONTRIBUTING*|INSTALL*|SETUP*' .Repository: makeplane/developer-docs
Length of output: 50381
package.json:8 — Keep the build preflight cross-platform.
true isn’t available in Windows package-script shells, so a failed git fetch --unshallow stops pnpm build before vitepress build docs runs. Use a Node-based no-op fallback instead.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@package.json` at line 8, Update the package.json build script’s failed git
fetch fallback to use a Node-based no-op command instead of `true`, ensuring the
subsequent `vitepress build docs` runs consistently across Windows and Unix
shells.
Summary by CodeRabbit
Documentation
Chores