Skip to content

Commit

Permalink
fix(ewd): principles navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtaholik committed Dec 6, 2024
1 parent 49b5503 commit 29369b8
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions apps/epic-web/src/templates/principles-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ function findCurrentAndAdjacentItems(
item: subsection,
parentSlug: section.slug,
})

subsection.principles?.forEach((principle) => {
flattenedItems.push({
item: principle,
Expand All @@ -241,18 +240,16 @@ function findCurrentAndAdjacentItems(
})
})

// Find current item index based on full path match
// Find current item index based on exact path match
const currentIndex = flattenedItems.findIndex(
({item, parentSlug, subsectionSlug}) => {
if (subsectionSlug) {
return currentPath.includes(
`/principles/${parentSlug}/${subsectionSlug}/${item.slug}`,
)
}
if (parentSlug) {
return currentPath.includes(`/principles/${parentSlug}/${item.slug}`)
}
return currentPath === `/principles/${item.slug}`
const expectedPath = subsectionSlug
? `/principles/${parentSlug}/${subsectionSlug}/${item.slug}`
: parentSlug
? `/principles/${parentSlug}/${item.slug}`
: `/principles/${item.slug}`

return currentPath === expectedPath
},
)

Expand Down

0 comments on commit 29369b8

Please sign in to comment.