fix(nav): use segment-boundary route matching to prevent false positives
Extracts isActiveRoute() into shared nav module. Matches exact path or path + '/' prefix, preventing /settings from matching /settings-advanced. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { mobileNavItems } from './nav';
|
||||
import { mobileNavItems, isActiveRoute } from './nav';
|
||||
</script>
|
||||
|
||||
<nav
|
||||
@@ -8,7 +8,7 @@
|
||||
class="hidden md:flex lg:hidden gap-2 items-center p-2"
|
||||
>
|
||||
{#each mobileNavItems as item (item.href)}
|
||||
{@const active = $page.url.pathname.startsWith(item.href)}
|
||||
{@const active = isActiveRoute(item.href, $page.url.pathname)}
|
||||
<a
|
||||
href={item.href}
|
||||
aria-current={active ? 'page' : undefined}
|
||||
|
||||
Reference in New Issue
Block a user