diff options
author | 2022-11-02 01:38:45 +0530 | |
---|---|---|
committer | 2022-11-01 16:08:45 -0400 | |
commit | 0bab357c48605462ead893cfae843ef159d16e82 (patch) | |
tree | 95912c7a0430d2c6f72b2cfe5fdf4e9d3dd31cd1 /examples/blog/src | |
parent | b6afe2c1db613aabf3139fb58e0fc2ab60322f37 (diff) | |
download | astro-0bab357c48605462ead893cfae843ef159d16e82.tar.gz astro-0bab357c48605462ead893cfae843ef159d16e82.tar.zst astro-0bab357c48605462ead893cfae843ef159d16e82.zip |
fix: consider trailing slashes when calculating current path in blog example (#5272)
Diffstat (limited to 'examples/blog/src')
-rw-r--r-- | examples/blog/src/components/HeaderLink.astro | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/blog/src/components/HeaderLink.astro b/examples/blog/src/components/HeaderLink.astro index d82155c62..e8e2e103b 100644 --- a/examples/blog/src/components/HeaderLink.astro +++ b/examples/blog/src/components/HeaderLink.astro @@ -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}> |