You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[
'@docusaurus/plugin-client-redirects',
{
fromExtensions: ['html'],
createRedirects: function (path) {
// redirect to /docs from /docs/introduction,
// as introduction has been made the home doc
if (allDocHomesPaths.includes(path)) {
return [`${path}/introduction`];
}
},
},
],
Expected behavior
Using a baseUrl should not require the user to reconfigure the plugin
Here we need to modify the behavior of createRedirects, becase the path argument includes the baseUrl.
I observed two related issues while reproducing this issue.
baseUrl field fails validation when there is no ending slash
While building with baseUrl: /build, I receive Validation Errors from the client-redirects plugin.
Error: Some created redirects are invalid:
- {"from":"//blog.html","to":"//blog"} => Validation error: "from" is not a valid pathname. Pathname should start with / and not contain any domain or query string
// followed by many more lines of similar errors
To resolve this, we can add a slash at the end. i.e. baseUrl: /build/ works. However, I'm not sure if this is the intended behavior. (Edit: This is noted in issue #2978 already, PR #2987 will resolve the issue)
No redirect occurs even when using default baseUrl
Even when we use baseUrl: '/', no redirection occurs when we visit http://localhost:5000/docs/introduction (or https://v2.docusaurus.io/docs/introduction). Instead, we go to the 404 page.
To resolve this in D2, we can add an ending slash to every element in allDocHomePaths. (e.g For the link above to work in particular, we should append a slash to /docs)
// append an ending slash to all array elements like thisconstallDocHomesPaths=['/docs/','/docs/next/',
...versions.slice(1).map((version)=>`/docs/${version}/`),];
I will make a PR to resolve the website redirection issue in point 2 together with the original issue for now
🐛 Bug Report
Discussed here:
#2969 (comment)
Have you read the Contributing Guidelines on issues?
Yes
To Reproduce
baseUrl: '/build'
"serve:v2": "serve website",
/docs/versionX/introduction
to/docs/versionX/
that the plugin setup should work like it does without a baseUrl (http://localhost:5000/build/docs/introduction)The conf is currently:
Expected behavior
Using a baseUrl should not require the user to reconfigure the plugin
Here we need to modify the behavior of
createRedirects
, becase the path argument includes the baseUrl.For the extensions it has been fixed in #2969
Actual Behavior
createRedirects
is baseUrl sensitiveWhat we should probably do?
The postBuild hook receives props.routePaths, but these paths includes the baseUrl, and we forward these paths to other plugin methods:
We should probably instead make these paths relative to the baseUrl so that the plugin config is not baseUrl sensitive.
(this probably requires reverting some changes from #2969 , as passing the baseUrl as arg to some methods would not be needed anymore)
The text was updated successfully, but these errors were encountered: