feat: prefetching and instant page switching

This commit is contained in:
Ax333l 2022-10-23 22:08:10 +02:00 committed by afn
parent 9b97f062c6
commit ea599f2397

View File

@ -1,10 +1,20 @@
<script>
import { page } from '$app/stores';
import { page, navigating } from '$app/stores';
export let href = '/';
$: current = href === $page.url.pathname;
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 {href}>
<a data-sveltekit-prefetch {href}>
<li class:selected={current === true}>
<slot />
</li>