diff --git a/src/components/dynamicNav.tsx b/src/components/dynamicNav.tsx index 8c58a61fe1b2e..a7061c75e6daf 100644 --- a/src/components/dynamicNav.tsx +++ b/src/components/dynamicNav.tsx @@ -1,5 +1,3 @@ -import {Fragment} from 'react'; - import {serverContext} from 'sentry-docs/serverContext'; import {sortPages} from 'sentry-docs/utils'; import {getUnversionedPath, VERSION_INDICATOR} from 'sentry-docs/versioning'; @@ -100,8 +98,35 @@ type ChildrenProps = { showDepth?: number; }; -export function Children({tree, path, exclude = [], showDepth = 0}: ChildrenProps) { - return {renderChildren(tree, exclude, path, showDepth)}; +function TopLevelChildren({tree, path, exclude = [], showDepth = 0}: ChildrenProps) { + return sortPages( + tree.filter( + ({name, node}) => + node && + !!node.context.title && + name !== '' && + exclude.indexOf(node.path) === -1 && + !node.context.sidebar_hidden + ), + ({node}) => node! + ).map(({node, children: nodeChildren}) => { + // will not be null because of the filter above + if (!node) { + return null; + } + return ( + + {renderChildren(nodeChildren, exclude, path, showDepth, 1)} + + ); + }); } type Props = { @@ -171,12 +196,12 @@ export function DynamicNav({ activeClassName="active" data-sidebar-link > -
{title}
+ {title} {withChevron && } ) : (
-
{title}
+ {title}
); @@ -184,12 +209,12 @@ export function DynamicNav({
  • {header} {(!collapse || isActive) && entity.children && ( -