sitemap: fail the build when a section or its dates go missing - #5870
Merged
Merged
Conversation
content-urls.get.ts catches its own errors, so a collection that fails to query or a source glob that matches nothing just leaves that section out of /sitemap.xml. git-lastmod.mjs returns nothing when `git log` fails, so every git-dated page silently loses its lastmod. Neither failed a build. A prerender:generate hook now checks the rendered /sitemap.xml and marks the route as errored, which fails the build under failOnError, when a content section (docs, handbook, changelog, blog, customer-stories, ebooks, whitepaper) has no URLs, or when a section dated only from git has no lastmod on any URL. The blueprints are not required, since a build without access to the private library has none by design.
✅ Deploy Preview for flowfuse-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
Author
|
FYI: the failing build here isn't caused by this PR. Tracked in https://github.com/FlowFuse/engineering/issues/460. It's resolved now, re-running the checks. |
@nuxtjs/sitemap does not prerender /sitemap.xml through Nitro's route loop. It renders the file itself in prerender:done, so the prerender:generate hook never saw it and the check never ran. The module passes the rendered sitemaps to the Nuxt hook sitemap:prerender:done instead, and a throw there fails the build. Checked by building with a section that does not exist added to the list: the build fails with "[sitemap] no /no-such-section/ URLs".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Two sitemap failures pass silently today:
server/api/__sitemap__/content-urls.get.tscatches its own errors, so a collection that fails to query, or a glob that matches nothing, drops that whole section from/sitemap.xml.lib/git-lastmod.mjsreturns nothing whengit logfails, so every git-dated page loses itslastmod.This checks the rendered
/sitemap.xmlat prerender time and fails the build when a content section has no URLs, or when a section dated only from git has nolastmodat all. Blueprints are not required, since a build without access to the private library has none.Production's current sitemap passes the check. A build with a section that does not exist added to the list fails with
[sitemap] no /no-such-section/ URLs.Related Issue(s)
Follow-up to #5777
Checklist