From 2adf3b56eb74df2d39d0c4dfdc753c9b9911dd4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=A0=E3=81=84=E3=81=8D?= <13312135+daikiejp@users.noreply.github.com> Date: Tue, 30 Jan 2024 06:50:26 -0500 Subject: [PATCH] chore: support isActive link all subpages (#9694) * chore: support isActive link all subpages * Update examples/blog/src/components/HeaderLink.astro Co-authored-by: Florian Lefebvre --------- Co-authored-by: Nate Moore Co-authored-by: Florian Lefebvre --- examples/blog/src/components/HeaderLink.astro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/blog/src/components/HeaderLink.astro b/examples/blog/src/components/HeaderLink.astro index 3dd439be1a..bb600fb65a 100644 --- a/examples/blog/src/components/HeaderLink.astro +++ b/examples/blog/src/components/HeaderLink.astro @@ -6,7 +6,8 @@ type Props = HTMLAttributes<'a'>; const { href, class: className, ...props } = Astro.props; const { pathname } = Astro.url; -const isActive = href === pathname || href === pathname.replace(/\/$/, ''); +const subpath = pathname.match(/[^\/]+/g); +const isActive = href === pathname || href === '/' + subpath?.[0]; ---