diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/blog/src/components/HeaderLink.astro | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/examples/blog/src/components/HeaderLink.astro b/examples/blog/src/components/HeaderLink.astro index 3dd439be1..bb600fb65 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]; --- <a href={href} class:list={[className, { active: isActive }]} {...props}> |