fix(sitemap): trigger autoGenerate on publish and unpublish actions#417
Open
Jurdio wants to merge 2 commits into
Open
fix(sitemap): trigger autoGenerate on publish and unpublish actions#417Jurdio wants to merge 2 commits into
Jurdio wants to merge 2 commits into
Conversation
In Strapi 5, publish and unpublish are separate document service actions and do not go through the update action. The previous allowlist only included create, update and delete, so publishing or unpublishing a document never triggered sitemap regeneration. Adds publish and unpublish to the allowlist so autoGenerate works correctly in Strapi 5 draft-and-publish workflows. Fixes pluginpal#416
🦋 Changeset detectedLatest commit: 75e708b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Problem
autoGenerate: truedoes not regenerate the sitemap when a document is published or unpublished in Strapi 5. The sitemap only updates on the next cron tick.Closes #416
Root cause
The
autoGenerateMiddlewareallowlist only includescreate,updateanddelete:In Strapi 5,
publishandunpublishare separate document service actions — they do not go throughupdate. So publishing a document silently skips the middleware and the sitemap is never regenerated.Fix
Add
publishandunpublishto the allowlist:Testing
autoGenerate: truein plugin config withexcludeDrafts: true/api/sitemap/index.xml— entry now appears immediately without waiting for cronRelated