|
15 | 15 | let navStatus = $state(false); |
16 | 16 | let toggleNav = nav.toggle; |
17 | 17 | let closeNav = nav.close; |
18 | | - let currentUrl = $state($page.url.pathname); |
19 | | - const hasPath = (key: string) => currentUrl.includes(key); |
| 18 | + let activeUrl = $state($page.url.pathname); |
| 19 | + const hasPath = (key: string) => activeUrl.includes(key); |
20 | 20 | let pageStatus = $derived(hasPath("pages")); |
21 | 21 | let componentStatus = $derived(hasPath("components")); |
22 | | - // $inspect("currentUrl: ", currentUrl); |
23 | | - // $inspect("pageStatus: ", pageStatus); |
24 | | - // $inspect("componentStatus: ", componentStatus); |
25 | 22 |
|
26 | 23 | $effect(() => { |
27 | 24 | navStatus = nav.isOpen; |
28 | | - currentUrl = $page.url.pathname; |
| 25 | + activeUrl = $page.url.pathname; |
29 | 26 | isOpen = sidebarUi.isOpen; |
30 | 27 | // pageStatus = hasPath("pages"); |
31 | 28 | // componentStatus = hasPath("components"); |
|
40 | 37 |
|
41 | 38 | $effect(() => { |
42 | 39 | metaTags = $page.data.pageMetaTags ? deepMerge($page.data.layoutMetaTags, $page.data.pageMetaTags) : data.layoutMetaTags; |
| 40 | + activeUrl = $page.url.pathname; |
| 41 | + $inspect("activeUrl in layout: ", activeUrl); |
43 | 42 | }); |
44 | 43 | </script> |
45 | 44 |
|
|
67 | 66 | <Darkmode class="hidden sm:block" /> |
68 | 67 | </div> |
69 | 68 | {/snippet} |
70 | | - <NavUl class="md:space-x-6 lg:space-x-8"> |
| 69 | + <NavUl class="md:space-x-6 lg:space-x-8" {activeUrl}> |
71 | 70 | <NavLi href="/pages/coverage">Coverage</NavLi> |
72 | 71 | <NavLi href="/pages/about">About</NavLi> |
73 | 72 | <NavLi class="sm:hidden" href="https://github.com/shinokada/svelte-5-ui-lib">Repo</NavLi> |
|
0 commit comments