refactor: add and use router event store

This commit is contained in:
Ax333l
2022-10-24 16:04:55 +02:00
committed by afn
parent ea599f2397
commit 4feed9982b
3 changed files with 59 additions and 38 deletions

View File

@ -1,21 +1,10 @@
<script>
import { page, navigating } from '$app/stores';
import RouterEvents from '../../../data/RouterEvents';
export let href = '/';
let nav = null;
$: current_page = $page.url.pathname;
$: {
nav = $navigating;
if (nav != null && nav.to != null) {
current_page = nav.to.url.pathname;
}
}
$: current = href === current_page;
</script>
<a data-sveltekit-prefetch {href}>
<li class:selected={current === true}>
<li class:selected={href === $RouterEvents.target_url.pathname}>
<slot />
</li>
</a>