Skip to content

Commit

Permalink
fix(surround): do not use parent item if it exists as first child
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Nov 29, 2024
1 parent 7f8f128 commit 5810fc6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/runtime/internal/surround.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ export async function generateItemSurround<T extends PageCollectionItemBase>(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
Expand Down

0 comments on commit 5810fc6

Please sign in to comment.