Skip to content

feat(sitemap): support root-level sitemap fallback for dynamic routes#19

Open
mateussilva92 wants to merge 1 commit intocode-forge-io:mainfrom
mateussilva92:feat/root-handle-sitemap
Open

feat(sitemap): support root-level sitemap fallback for dynamic routes#19
mateussilva92 wants to merge 1 commit intocode-forge-io:mainfrom
mateussilva92:feat/root-handle-sitemap

Conversation

@mateussilva92
Copy link

Fixes #18

Description

This PR enhances the Remix/React Router v7 sitemap generation by introducing a root handle fallback.

Previously, only route-level handle.sitemap functions were supported. Now:

  • If a route defines a handle.sitemap, it will run for that route.
  • If a route does not define a sitemap handle, the root.tsx sitemap function will run as a fallback if it exists.

This ensures consistent sitemap generation across all routes and reduces duplication for shared logic like multilingual alternates.

Type of change

Please mark relevant options with an x in the brackets.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Algorithm update - updates algorithm documentation/questions/answers etc.
  • Other (please describe):

How Has This Been Tested?

This was tested locally directly on a React Router v7 project that I'm currently working on. I defined a handle function that returned a object with a sitemap function on my root.tsx and then checked the sitemap generated.

  • Integration tests
  • Unit tests
  • Manual tests
  • No tests required

Reviewer checklist

Mark everything that needs to be checked before merging the PR.

  • Check if the UI is working as expected and is satisfactory
  • Check if the code is well documented
  • Check if the behavior is what is expected
  • Check if the code is well tested
  • Check if the code is readable and well formatted
  • Additional checks (document below if any)

Screenshots (if appropriate):

Questions (if appropriate):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Global handle function for Remix/React Router v7

1 participant