Skip to content

Conversation

@colbywhite
Copy link
Collaborator

@colbywhite colbywhite commented Nov 24, 2025

Summary

This replaces the logic to calculate lastmod via multiple git commands into a single git command.

Notes

  • These lastmods will never be 100% accurate since each page is built from several files, not just one. That's known and accepted.
  • The previous logic for determining which source file to use was kept, however it only works for Starlight's content files. The rest of the pages (i.e. src/pages/*.astro) will end up with a lastmod that is updated every build. I investigated using Astro's IntegrationResolvedRoute to determine the source file via a custom integration that wrapped @astrojs/sitemap. But it became simpler to just keep things in a serializer. (I will keep investigating this path via a PR back to astro directly. That is likely a better place for this logic.)
  • Optimise sitemap creation #26710 was created while this work was in flight. That PR was merged and this was continued on top of it. Most of the differences are refactors but some key behavioral diffs are
    • This uses readline to parse the output of the git command. This treats it as a stream and ends up faster while limiting any memory/heap hit from loading all the output into a JS string.
    • Handles different timezone in the git history by leveraging JS' Date class.
    • Logs output in a manner that matches Astro's logging style

Screenshots

Resulting sitemap

Screenshot 2025-11-24 at 14 29 15

Build output

Screenshot 2025-11-24 at 14 28 40

@github-actions
Copy link
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
*.ts @cloudflare/pcx-content-engineering, @kodster28

@github-actions
Copy link
Contributor

@colbywhite colbywhite merged commit b4697aa into production Nov 24, 2025
12 checks passed
@colbywhite colbywhite deleted the sngl.lstmd.cmd branch November 24, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants