Skip to content

Commit

Permalink
possible fix for missing current url highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Sep 20, 2024
1 parent 0a87d41 commit e04dab3
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/components/RecMenu.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ const links: Link[] = Astro.props.links;
const className: string | string[] = Astro.props.className;
const isOpen = Astro.props.isOpen;
const currentPath = Astro.url.pathname;
const currentPathWithoutTrailingBackslash = currentPath.replace(/\/$/, '');
---

<script define:vars={{currentPath, links}}>

console.log(currentPath)
console.log(links.map(link => link.href))
</script>


<ul class:list={[className]} class="lg:min-w-max">
{links.map((link: Link) => (
<li>
Expand All @@ -29,7 +23,7 @@ console.log(links.map(link => link.href))
<Astro.self links={link.children} isOpen={isOpen}/>
</details>
) : (
<a href={link.href} class:list={[{"underline": (currentPath === link.href)}, "decoration-primary"]}>{link.text}</a>
<a href={link.href} class:list={[{"underline": (currentPathWithoutTrailingBackslash === link.href)}, "decoration-primary"]}>{link.text}</a>
)}
</li>
))}
Expand Down

0 comments on commit e04dab3

Please sign in to comment.