Skip to content

Commit 5810fc6

Browse files
committed
fix(surround): do not use parent item if it exists as first child
1 parent 7f8f128 commit 5810fc6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/runtime/internal/surround.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ export async function generateItemSurround<T extends PageCollectionItemBase>(que
2020
function flattedData(data: ContentNavigationItem[]) {
2121
const flatData = data.flatMap((item) => {
2222
const children: ContentNavigationItem[] = item.children ? flattedData(item.children) : []
23+
if (item.page === false || (children.length && children[0].path === item.path)) {
24+
return children
25+
}
2326

24-
return item.page === false ? children : [{ ...item, children: undefined }, ...children]
27+
return [{ ...item, children: undefined }, ...children]
2528
})
2629

2730
return flatData

0 commit comments

Comments
 (0)