Skip to content

Commit 99aedfc

Browse files
authored
Fix flashing 404 page on URL with trailing slash (#136)
1 parent 80213f5 commit 99aedfc

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

docusaurus.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,22 @@ const config: Config = {
188188
},
189189
},
190190
],
191+
// This is a fix for the flashing 404 page on URLs with a trailing slash:
192+
//
193+
// See: https://github.com/facebook/docusaurus/issues/5077
194+
[
195+
"@docusaurus/plugin-client-redirects",
196+
{
197+
createRedirects(existingPath: string) {
198+
if (!existingPath.endsWith("/")) {
199+
return `${existingPath}/`;
200+
}
201+
202+
// Return a falsy value: no redirect created
203+
return undefined;
204+
},
205+
},
206+
]
191207
],
192208
};
193209

package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"@typescript-eslint/parser": "^6.21.0",
5151
"eslint": "^8.56.0",
5252
"eslint-config-prettier": "^9.1.0",
53-
"@docusaurus/eslint-plugin": "^3.1.1"
53+
"@docusaurus/eslint-plugin": "^3.1.1",
54+
"@docusaurus/plugin-client-redirects": "^3.1.1"
5455
},
5556
"browserslist": {
5657
"production": [
@@ -67,4 +68,4 @@
6768
"engines": {
6869
"node": ">=18.17"
6970
}
70-
}
71+
}

0 commit comments

Comments
 (0)