mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-29 17:59:36 +02:00
Refactor navigation to use goto function
This commit is contained in:
parent
8d653ddf6c
commit
960062b499
2 changed files with 13 additions and 4 deletions
|
@ -1,10 +1,18 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getNumberOfAdventures } from "../../services/adventureService";
|
import { getNumberOfAdventures } from "../../services/adventureService";
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
|
async function goHome() {
|
||||||
|
goto('/');
|
||||||
|
}
|
||||||
|
async function goToLog() {
|
||||||
|
goto('/log');
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<div class="navbar bg-base-100">
|
<div class="navbar bg-base-100">
|
||||||
<div class="navbar-start">
|
<div class="navbar-start">
|
||||||
<button class="btn btn-primary mr-4 ml-2" on:click={() => window.location.href = '/'}>Home</button>
|
<button class="btn btn-primary mr-4 ml-2" on:click={goHome}>Home</button>
|
||||||
<button class="btn btn-primary" on:click={() => window.location.href = '/log'}>My Log</button>
|
<button class="btn btn-primary" on:click={goToLog}>My Log</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="navbar-center">
|
<div class="navbar-center">
|
||||||
<a class="btn btn-ghost text-xl" href="/">AdventureLog 🗺️</a>
|
<a class="btn btn-ghost text-xl" href="/">AdventureLog 🗺️</a>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
import campingDrawing from "$lib/assets/camping.svg";
|
import campingDrawing from "$lib/assets/camping.svg";
|
||||||
function navToLog() {
|
async function navToLog() {
|
||||||
window.location.href = '/log';
|
goto('/log');
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue