diff options
author | 2022-09-13 15:02:32 -0400 | |
---|---|---|
committer | 2022-09-13 14:02:32 -0500 | |
commit | 234057b020d611a334f8ef8cfa4694245b89a600 (patch) | |
tree | 3724415de7840654228e15b408331f854136c35c /examples/blog/src | |
parent | 013d15554eafb1d945c79403bd2eb05a38dbb176 (diff) | |
download | astro-234057b020d611a334f8ef8cfa4694245b89a600.tar.gz astro-234057b020d611a334f8ef8cfa4694245b89a600.tar.zst astro-234057b020d611a334f8ef8cfa4694245b89a600.zip |
Template (Blog): fix `HeaderLink` `isActive` check (#4647)
* remove trailing slashes when checking active href
* use simpler regex
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
* remove unused code
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'examples/blog/src')
-rw-r--r-- | examples/blog/src/components/HeaderLink.astro | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/examples/blog/src/components/HeaderLink.astro b/examples/blog/src/components/HeaderLink.astro index 7f509e38c..d82155c62 100644 --- a/examples/blog/src/components/HeaderLink.astro +++ b/examples/blog/src/components/HeaderLink.astro @@ -2,7 +2,7 @@ export interface Props extends astroHTML.JSX.AnchorHTMLAttributes {} const { href, class: className, ...props } = Astro.props; -const isActive = href === Astro.url.pathname; +const isActive = href === Astro.url.pathname.replace(/\/$/, ''); --- <a href={href} class:list={[className, { active: isActive }]} {...props}> |