Skip to content

Commit

Permalink
fix(SidebarNavigation): active link in production
Browse files Browse the repository at this point in the history
  • Loading branch information
goulvenclech committed Jun 14, 2024
1 parent b3e3c5d commit 1489b5d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/polite-bikes-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@goulvenclech/astropi": patch
---

Fixes active link on sidebar navigation.
6 changes: 5 additions & 1 deletion packages/astropi/components/SidebarNavigation.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const archetype = getCurrentArchetype(Astro.url)
const allEntries = await getCollectionEntries(archetype.collection)
// Check if a link is the current page, used to apply the active class
const isCurrentPage = (path: string) => {
const currentPage = Astro.url.pathname.split("/").pop()
const currentPage = Astro.url.pathname
.split("/")
// In production the pathname ends with a slash, so let's remove empty strings
.filter((s) => s)
.pop()
const pathPage = path.split("/").pop()
return pathPage === currentPage
}
Expand Down

0 comments on commit 1489b5d

Please sign in to comment.