diff --git a/src/runtime/internal/surround.ts b/src/runtime/internal/surround.ts index 9aa20fcfc..688a95d50 100644 --- a/src/runtime/internal/surround.ts +++ b/src/runtime/internal/surround.ts @@ -20,8 +20,11 @@ export async function generateItemSurround(que function flattedData(data: ContentNavigationItem[]) { const flatData = data.flatMap((item) => { const children: ContentNavigationItem[] = item.children ? flattedData(item.children) : [] + if (item.page === false || (children.length && children[0].path === item.path)) { + return children + } - return item.page === false ? children : [{ ...item, children: undefined }, ...children] + return [{ ...item, children: undefined }, ...children] }) return flatData