Skip to content

Commit

Permalink
fix: root node should redirect to its first child (#964)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Jun 5, 2024
1 parent 08fc1b5 commit 757223b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/fdr-sdk/src/navigation/utils/findNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export function findNode(root: FernNavigation.RootNode, slug: string[]): Node {
};
}

// if the slug points matches the root node, redirect to the root node's pointsTo
if (root.type === "root" && root.slug === slugToFind && root.pointsTo != null) {
return { type: "redirect", redirect: root.pointsTo };
}

const redirect = hasPointsTo(found.node) ? found.node.pointsTo : version?.pointsTo ?? root.pointsTo;

if (redirect == null || redirect === slugToFind) {
Expand Down

0 comments on commit 757223b

Please sign in to comment.