()
| 52 | // Map each docs entry to the ISO timestamp of its most recent git commit. |
| 53 | // Empty Map when git history is unavailable (shallow CI clones, etc.). |
| 54 | function buildDocsLastmodMap() { |
| 55 | const map = new Map(); |
| 56 | try { |
| 57 | const out = execSync( |
| 58 | "git log --pretty=format:%cI --name-only --diff-filter=AMR -- 'src/content/docs/**/*.mdx' 'src/content/docs/**/*.md'", |
| 59 | { encoding: "utf-8" }, |
| 60 | ); |
| 61 | let currentDate = ""; |
| 62 | for (const raw of out.split("\n")) { |
| 63 | const line = raw.trim(); |
| 64 | if (!line) continue; |
| 65 | if (/^\d{4}-\d{2}-\d{2}T/.test(line)) { |
| 66 | currentDate = line; |
| 67 | } else if (currentDate && !map.has(line)) { |
| 68 | map.set(line, currentDate); |
| 69 | } |
| 70 | } |
| 71 | } catch { |
| 72 | // No git history available. Leave the map empty. |
| 73 | } |
| 74 | return map; |
| 75 | } |
| 76 | |
| 77 | const docsLastmod = buildDocsLastmodMap(); |
| 78 |
no test coverage detected