mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
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 {}
|
export interface Props extends astroHTML.JSX.AnchorHTMLAttributes {}
|
||||||
|
|
||||||
const { href, class: className, ...props } = Astro.props;
|
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}>
|
<a href={href} class:list={[className, { active: isActive }]} {...props}>
|
||||||
|
|
Loading…
Add table
Reference in a new issue