fix: consider trailing slashes when calculating current path in blog example (#5272)
This commit is contained in:
parent
b6afe2c1db
commit
0bab357c48
1 changed files with 3 additions and 1 deletions
|
@ -2,7 +2,9 @@
|
|||
export interface Props extends astroHTML.JSX.AnchorHTMLAttributes {}
|
||||
|
||||
const { href, class: className, ...props } = Astro.props;
|
||||
const isActive = href === Astro.url.pathname.replace(/\/$/, '');
|
||||
|
||||
const { pathname } = Astro.url;
|
||||
const isActive = href === pathname || href === pathname.replace(/\/$/, '');
|
||||
---
|
||||
|
||||
<a href={href} class:list={[className, { active: isActive }]} {...props}>
|
||||
|
|
Loading…
Reference in a new issue