Skip to content

Commit

Permalink
fix(surround): handle missing path
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Dec 3, 2024
1 parent 722a9e7 commit 59c69bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/runtime/internal/surround.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export async function generateItemSurround<T extends PageCollectionItemBase>(que

const flatData = flattedData(navigation)
const index = flatData.findIndex(item => item.path === path)
const beforeItems = flatData.slice(index - before, index)
const afterItems = flatData.slice(index + 1, index + after + 1)
const beforeItems = index === -1 ? [] : flatData.slice(index - before, index)
const afterItems = index === -1 ? [] : flatData.slice(index + 1, index + after + 1)

return [
...(Array.from({ length: before }).fill(null).concat(beforeItems).slice(beforeItems.length)),
Expand Down

0 comments on commit 59c69bc

Please sign in to comment.