Skip to content

Instantly share code, notes, and snippets.

@SergioJuniorCE
Created November 29, 2021 07:57
Show Gist options
  • Save SergioJuniorCE/4f5e926b4a78a67c57c526004e1b64bc to your computer and use it in GitHub Desktop.
Save SergioJuniorCE/4f5e926b4a78a67c57c526004e1b64bc to your computer and use it in GitHub Desktop.
goto function svelte
<script>
import { goto } from '$app/navigation';
import { page } from '$app/stores';
export let title;
export let href;
function goTo() {
goto(href, {
replaceState: true
});
}
</script>
<li class="nav-item">
<a
class="nav-link"
class:active={$page.path === `/${href}`}
aria-current="page"
on:click={goTo}
{href}>{title}</a
>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment