@@ -24,7 +24,7 @@ import { parseFrontmatter, summaryFromBody } from "./lib/frontmatter.mjs";
2424import { listEntryFiles , idMatchesFile } from "./lib/entry-files.mjs" ;
2525import { entryPageHtml , scriptJson } from "./lib/entry-page.mjs" ;
2626import { LinkError , makeLinkResolver , caseMismatch } from "./lib/links.mjs" ;
27- import { atomFeed , catalogCsv , homeJsonLd , sitemapXml } from "./lib/exports.mjs" ;
27+ import { atomFeed , catalogCsv , commitDatesFromLog , DATED_PATHS , homeJsonLd , sitemapXml } from "./lib/exports.mjs" ;
2828import { schemaErrors } from "./lib/schema-check.mjs" ;
2929import { llmsFullTxt , llmsTxt } from "./lib/llms.mjs" ;
3030import { deprecationReason , MarkdownError , renderBlocks , renderInline , splitEntryBody } from "./lib/markdown.mjs" ;
@@ -222,33 +222,23 @@ function headMetaHtml(site, stats, generatedAt, hasCard) {
222222
223223/**
224224 * Repo-relative file => date of its last commit, from one `git log` over the
225- * catalog and stacks . The sitemap's lastmod must never be earlier than the
225+ * catalog, stacks and docs (DATED_PATHS) . The sitemap's lastmod must never be earlier than the
226226 * last content change, and an entry's `verified` date is not that. Empty when
227227 * git is unavailable (a tarball, a shallow CI checkout with no history).
228228 */
229229function lastCommitDates ( ) {
230- const dates = new Map ( ) ;
231230 try {
232- const out = execFileSync ( "git" , [ "log" , "--format=%x00%cs" , "--name-only" , "--" , "catalog" , "stacks" ] , {
231+ const out = execFileSync ( "git" , [ "log" , "--format=%x00%cs" , "--name-only" , "--" , ... DATED_PATHS ] , {
233232 cwd : ROOT ,
234233 encoding : "utf8" ,
235234 maxBuffer : 64 * 1024 * 1024 ,
236235 stdio : [ "ignore" , "pipe" , "ignore" ] ,
237236 } ) ;
238- let date = null ;
239- for ( const line of out . split ( "\n" ) ) {
240- if ( line . startsWith ( "\0" ) ) {
241- date = line . slice ( 1 ) . trim ( ) ;
242- continue ;
243- }
244- const file = line . trim ( ) ;
245- // Newest commit first, so the first date seen for a file is its latest.
246- if ( file && date && ! dates . has ( file ) ) dates . set ( file , date ) ;
247- }
237+ return commitDatesFromLog ( out ) ;
248238 } catch {
249239 // No git: the sitemap falls back to the build date.
240+ return new Map ( ) ;
250241 }
251- return dates ;
252242}
253243
254244function robotsTxt ( site ) {
@@ -491,7 +481,7 @@ function writeCategoryPages({ entries, config, stats, stamp, hasCard, now }) {
491481 * docs/ guides as guide/<id>/ pages. Links to entries go to their pages,
492482 * links to another guide go to its page, anything else to GitHub.
493483 */
494- function writeGuidePages ( { entries, config, stats, stamp, hasCard } ) {
484+ function writeGuidePages ( { entries, config, stats, stamp, hasCard, modified = new Map ( ) } ) {
495485 const written = [ ] ;
496486 const errors = [ ] ;
497487 const resolverFor = linkResolvers ( entries , config , "../../entry/" ) ;
@@ -516,7 +506,7 @@ function writeGuidePages({ entries, config, stats, stamp, hasCard }) {
516506 } ;
517507 try {
518508 const rendered = renderGuide ( fs . readFileSync ( path . join ( ROOT , guide . path ) , "utf8" ) , { file : guide . path , resolveLink } ) ;
519- writeOut ( path . join ( "guide" , guide . id , "index.html" ) , guidePageHtml ( { guide, rendered, site : config . site , stamp, total : stats . total , hasCard } ) ) ;
509+ writeOut ( path . join ( "guide" , guide . id , "index.html" ) , guidePageHtml ( { guide, rendered, site : config . site , stamp, total : stats . total , hasCard, modified : modified . get ( guide . path ) || null } ) ) ;
520510 written . push ( `guide/${ guide . id } /index.html` ) ;
521511 } catch ( err ) {
522512 errors . push ( err . message ) ;
@@ -695,15 +685,16 @@ function main() {
695685 const categoriesInSitemap = Object . keys ( config . categories )
696686 . filter ( ( cat ) => visible . some ( ( e ) => e . category === cat ) )
697687 . map ( ( id ) => ( { id, lastmod : stamp } ) ) ;
698- writeOut ( "sitemap.xml" , sitemapXml ( { site : config . site , entries : visible , stacks, stamp, modified : lastCommitDates ( ) , categories : categoriesInSitemap , guides : config . guides } ) ) ;
688+ const modified = lastCommitDates ( ) ;
689+ writeOut ( "sitemap.xml" , sitemapXml ( { site : config . site , entries : visible , stacks, stamp, modified, categories : categoriesInSitemap , guides : config . guides } ) ) ;
699690 writeOut ( "robots.txt" , robotsTxt ( config . site ) ) ;
700691 writeOut ( "404.html" , notFoundHtml ( config . site ) ) ;
701692 writeOut ( path . join ( "freshness" , "index.html" ) , freshnessPageHtml ( { stats : fresh , site : config . site , stamp, total : stats . total , hasCard } ) ) ;
702693
703694 const pages = writeEntryPages ( { entries, bodies, config, stats, stamp, hasCard, now, usedIn } ) ;
704695 const stackPages = writeStackPages ( { stacks, entries, config, stats, stamp, hasCard, now } ) ;
705696 const categoryPages = writeCategoryPages ( { entries : visible , config, stats, stamp, hasCard, now } ) ;
706- const guidePages = writeGuidePages ( { entries, config, stats, stamp, hasCard } ) ;
697+ const guidePages = writeGuidePages ( { entries, config, stats, stamp, hasCard, modified } ) ;
707698 const pageErrors = [
708699 ...stackErrors ,
709700 ...pages . errors ,
0 commit comments