fix(sitemap): remove layout routes from the sitemap list#20
Open
mateussilva92 wants to merge 1 commit intocode-forge-io:mainfrom
Open
fix(sitemap): remove layout routes from the sitemap list#20mateussilva92 wants to merge 1 commit intocode-forge-io:mainfrom
mateussilva92 wants to merge 1 commit intocode-forge-io:mainfrom
Conversation
Comment on lines
+38
to
+42
| return Object.values(routes) | ||
| .filter((route) => { | ||
| // Filter out layouts from the routes | ||
| return route?.path !== undefined || route?.index | ||
| }) |
There was a problem hiding this comment.
Wouldn't that ignore all child routes here? I think in the case of a layout route, all children should be spread into the parent for processing.
Author
There was a problem hiding this comment.
Not really. If that was the case the old code would have ignore them already since it only goes one level deep. The routes used here should come from virtual:react-router/server-build which already has all the routes flattened so none of the routes have any children, this can even be checked on the type of InternalServerRoute which even omits the children.
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.
Fixes #12
Description
This PR fixes an issue where some routes were being duplicated in the sitemap for Remix/React Router v7.
This was being cause by layout routes were being treated as normal routes which they shouldn't be since they don't have any path associated to them that the user can navigate to.
The changes include:
undefinedor if the index is set totrue.Type of change
Please mark relevant options with an
xin the brackets.How Has This Been Tested?
This was tested locally directly on a React Router v7 project that I'm currently working on. I defined layout for the home route which cased the home route to appear twice on the sitemap. After the changes it only appear once.
Reviewer checklist
Mark everything that needs to be checked before merging the PR.
Screenshots (if appropriate):
Questions (if appropriate):