From 757223bbcd20c189de7133a927767aa09fd70cf0 Mon Sep 17 00:00:00 2001 From: Andrew Jiang Date: Tue, 4 Jun 2024 23:03:35 -0400 Subject: [PATCH] fix: root node should redirect to its first child (#964) --- packages/fdr-sdk/src/navigation/utils/findNode.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/fdr-sdk/src/navigation/utils/findNode.ts b/packages/fdr-sdk/src/navigation/utils/findNode.ts index eb59f8411c..26c06109bd 100644 --- a/packages/fdr-sdk/src/navigation/utils/findNode.ts +++ b/packages/fdr-sdk/src/navigation/utils/findNode.ts @@ -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) {