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>
This commit is contained in:
Sami Jaber 2022-09-13 15:02:32 -04:00 committed by GitHub
parent 013d15554e
commit 234057b020
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,7 @@
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; const isActive = href === Astro.url.pathname.replace(/\/$/, '');
--- ---
<a href={href} class:list={[className, { active: isActive }]} {...props}> <a href={href} class:list={[className, { active: isActive }]} {...props}>