routesChunkName.json does not allow sub-route with same path as parent. #2917
Labels
better engineering
Not a bug or feature request
bug
An error in the Docusaurus core causing instability or issues with its execution
difficulty: advanced
Issues that are complex, e.g. large scoping for long-term maintainability.
documentation
The issue is related to the documentation of Docusaurus
pr: maintenance
This PR does not produce any behavior differences to end users when upgrading.
TLDR: this is not urgent, and there is a workaround, just opened this issue for documenting the problem so that we don't forget to fix this later.
This is related to:
#2905 (comment)
Problem
Currently the
routesChunkName.json
is a mapping frompath
tochunkNames
.The problem is that you might have 2 routes with the same path. It notably happens in such case:
The
DocsLayout
component is supposed to intercept any request, apply the layout, and render the doc we are currently on.But as we can make a doc the "home" (with
homePageId
), we end up with the parent and its child having the exact same path.In such case, the
routesChunkNames.json
perform a bad "merge" of the data of the 2 routes having the same path:This lead to runtime errors, as D2 is not able to load all the required chunks for a given page, and the component attribute overridden by the children. (in such case / renders the doc directly, without using the layout comp)
We should ensure that this does not happen, and allow a parent and its child route to have the same path without troubles. The
routesChunkName.json
could for example evolve to a new format, taking an array of values instead of a single value.Workaround:
The "parent" route can just omit the trailing /.
The ReactRouter matching still works and
routesChunkName.json
is able to add 2 paths instead of merging them:The text was updated successfully, but these errors were encountered: