<ListItem
selected={path.includes(item.to)}
|
<ListItem |
|
selected={path.includes(item.to)} |
That triggers whenever the current URL path happens to contain the destination.
For example, if you add a new src/routes/aboutfoo.svelte that'll set "About" as active.
I did this, instead:
selected={isActive(path, item.to)}
function isActive(path, to) {
if (to == path) {
return true
}
if (path.startsWith(to+"/")) {
return true
}
return false
}
The second if marks an item selected if the current URL is below. Whether one wants that or not depends on whether the NavigationDrawer contains just one level, or multiple. Highlighting only the most exact matching entry gets a little tricky...
smelte-sapper-template/src/routes/_layout.svelte
Lines 80 to 81 in 780ab5b
That triggers whenever the current URL path happens to contain the destination.
For example, if you add a new
src/routes/aboutfoo.sveltethat'll set "About" as active.I did this, instead:
The second if marks an item selected if the current URL is below. Whether one wants that or not depends on whether the NavigationDrawer contains just one level, or multiple. Highlighting only the most exact matching entry gets a little tricky...