MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / buildDocsLastmodMap

Function buildDocsLastmodMap

apps/docs/astro.config.mjs:54–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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.).
54function 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
77const docsLastmod = buildDocsLastmodMap();
78

Callers 1

astro.config.mjsFile · 0.85

Calls 2

hasMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected