From 254b954f1c2443fdc42c952ca40c6956ede87448 Mon Sep 17 00:00:00 2001 From: Cassidy Williams <1454517+cassidoo@users.noreply.github.com> Date: Sat, 14 Dec 2024 10:40:53 -0600 Subject: [PATCH] Add check for header link and trailing slash --- src/components/HeaderLink.astro | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/HeaderLink.astro b/src/components/HeaderLink.astro index 717cb2e..1fd1b56 100644 --- a/src/components/HeaderLink.astro +++ b/src/components/HeaderLink.astro @@ -1,6 +1,13 @@ --- const { href, class: className, ...props } = Astro.props; -let isActive = href === Astro.url.pathname; +let isActive; + +if (href === "/") { + isActive = Astro.url.pathname === href; +} else { + isActive = Astro.url.pathname.startsWith(href); +} + ---