Skip to content

Commit

Permalink
fix: version 404 on local preview
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity committed May 24, 2024
1 parent 8e28329 commit e898ee7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/commons/fdr-utils/src/getNavigationRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ export function getNavigationRoot(
});

if (hits[0] == null) {
// match on top-level versions if the slug starts with a version
// ignore the first item, which doesn't contain a version
for (const rootItem of root.items.slice(1)) {
if (rootItem.type === "versionGroup") {
const versionSlug = rootItem.slug.join("/");
if (slugArray.join("/").startsWith(rootItem.slug.join("/"))) {
return { type: "redirect", redirect: `/${versionSlug}` };
}
}
}

return undefined;
}

Expand Down

0 comments on commit e898ee7

Please sign in to comment.