2024-03-29 22:52:42 +00:00
|
|
|
<script lang="ts">
|
2024-04-02 18:28:14 +00:00
|
|
|
import { visitCount } from '$lib/utils/stores/visitCountStore';
|
2024-03-30 21:46:36 +00:00
|
|
|
import { goto } from '$app/navigation';
|
|
|
|
|
|
|
|
async function goHome() {
|
|
|
|
goto('/');
|
|
|
|
}
|
|
|
|
async function goToLog() {
|
|
|
|
goto('/log');
|
|
|
|
}
|
2024-04-02 18:04:27 +00:00
|
|
|
async function goToFeatured() {
|
|
|
|
goto('/featured');
|
|
|
|
}
|
2024-04-02 18:28:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
let count = 0;
|
|
|
|
visitCount.subscribe((value) => {
|
|
|
|
count = value;
|
|
|
|
});
|
|
|
|
|
|
|
|
// Set the visit count to the number of adventures stored in local storage
|
|
|
|
const isBrowser = typeof window !== 'undefined';
|
|
|
|
if (isBrowser) {
|
|
|
|
const storedAdventures = localStorage.getItem('adventures');
|
|
|
|
if (storedAdventures) {
|
|
|
|
let parsed = JSON.parse(storedAdventures);
|
|
|
|
visitCount.set (parsed.length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-29 22:52:42 +00:00
|
|
|
</script>
|
2024-04-01 21:35:21 +00:00
|
|
|
<div class="navbar bg-base-100 flex flex-col md:flex-row">
|
|
|
|
<div class="navbar-start flex justify-around md:justify-start">
|
|
|
|
<button class="btn btn-primary my-2 md:my-0 md:mr-4 md:ml-2" on:click={goHome}>Home</button>
|
2024-04-02 18:04:27 +00:00
|
|
|
<button class="btn btn-primary my-2 md:my-0 md:mr-4 md:ml-2" on:click={goToLog}>My Log</button>
|
|
|
|
<button class="btn btn-primary my-2 md:my-0" on:click={goToFeatured}>Featured</button>
|
2024-03-30 21:00:12 +00:00
|
|
|
</div>
|
2024-04-01 21:35:21 +00:00
|
|
|
<div class="navbar-center flex justify-center md:justify-center">
|
2024-03-30 21:00:12 +00:00
|
|
|
<a class="btn btn-ghost text-xl" href="/">AdventureLog 🗺️</a>
|
|
|
|
</div>
|
2024-04-02 18:04:27 +00:00
|
|
|
<div class="navbar-end flex justify-around md:justify-end mr-4">
|
2024-04-02 18:28:14 +00:00
|
|
|
<p>Adventures: {count} </p>
|
2024-03-30 21:00:12 +00:00
|
|
|
</div>
|
2024-04-01 21:35:21 +00:00
|
|
|
</div>
|