Proposal: createSitemapItems hook - a sitemap equivalent to createFeedItems #10081
Closed
2 tasks done
Labels
feature
This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Have you read the Contributing Guidelines on issues?
Description
There is already a way for users to control their RSS / Atom / JSON feeds with the
createFeedItems
hook.Wouldn't it be great if there was an equivalent API for sitemap?
This idea comes from the comment @slorber made here: #2604 (comment)
Has this been requested on Canny?
No
Motivation
I presently mutate my sitemap manually on each build as a post processing step. I've written about it here and I have historically done this for two reasons:
lastmod
to sitemap entries (something that is no longer necessary as of 3.2)If there was a hook that allowed control of the sitemap, I would no longer need to do 2 as a separate post processing step
API design
The proposal would be a similar design to the
createFeedItems
API that we landed in: #8378The
createFeedItems
API allows users to provide the following in the blog section of theirdocusaurus.config.js
:Usage looks like this:
Imagine a
createSitemapItems
property that could be provided as an additional property to the sitemap configuration.createSitemapItems
would be a function, which receives a single parameter. That parameter is an object with a number of properties. The most important of these would besitemapItems
. This would be a list of sitemap items. Users can then filter / mutate this list and return a new list which will be subsequently turned into the sitemap.xml.I'd imagine this probably being implemented around about here:
docusaurus/packages/docusaurus-plugin-sitemap/src/createSitemap.ts
Line 99 in da2c0b4
What do you think?
Have you tried building it?
Yes. See #10083
Self-service
The text was updated successfully, but these errors were encountered: