Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return the old path when next is missing from the url #13078

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions docusaurus/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,13 @@ const config = {
'@docusaurus/plugin-client-redirects',
{
createRedirects(existingPath) {
if (existingPath.includes('/extensions') && !existingPath.includes('/next') && !existingPath.includes('/v2')) {
return [
existingPath.replace('/extensions', '/extensions/next')
];
// This function is invoked once per existing doc page, and we
// must return the “old” routes that we want to map to that doc’s path
if (existingPath.startsWith('/extensions/next')) {
// Generate the "old" route we want to redirect from
const oldPath = existingPath.replace('/extensions/next', '/extensions');

return [oldPath];
}

return undefined; // Return a falsy value: no redirect created
Expand Down
Loading