HDDS-10903. Move sitemap check to Docusaurus build. #94
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.
What changes were proposed in this pull request?
In #93 we bumped Docusaurus to version 3.3.2. By upgrading to the 3.3.x line we can use the new createSitemapItems hook to remove the sitemap GitHub Actions job and make that part of the docusaurus build instead.
Background
We currently have a GitHub actions job that checks the sitemap.xml file generated by the Docusaurus build to make sure that all generated URLs use lowercase kebab-case. Since URLs are either generated from file names or front matter (with
slug
) and we already have checks for both of those, it is unlikely that an invalid URL format would be generated. The check is still nice to have though, so we can make it lighter weight by plugging it into the Docusaurus build instead.Code Changes
We use the docusaurus classic theme, which automatically includes the sitemap plugin. The change adds the sitemap hook to the part of the configuration that handles plugin configuration. For example, our docs plugin is configured here as well.
Dev Experience Changes
Anything that would generate a URL in a disallowed format should still be caught by the static checks, and all invalid instances will be listed in a single failure for quicker fixing. If somehow something slips through there, the docusaurus build will now fail when building the sitemap.
The build will abort after the first failure only, and the failure only occurs in a production build (
pnpm build
), not in development mode (pnpm start
ordocker compose up
). These are limitations with how the hook is implemented and invoked at build time.What is the link to the Apache Jira?
HDDS-10903
How was this patch tested?
test_name
and runningpnpm build
. The build fails and the error message is displayed.