Added hash-based routing using svelte-spa-router

This commit is contained in:
Dan Brown
2023-03-16 15:57:24 +00:00
parent a517ae588b
commit ad8aa1bdf0
9 changed files with 74 additions and 39 deletions

View File

@@ -1,4 +1,7 @@
<script lang="ts">
import Router, {location} from 'svelte-spa-router';
import routes from "./routes";
import Navbar from "./lib/Navbar.svelte";
import Sidebar from "./lib/Sidebar.svelte";
import Home from "./lib/Home.svelte";
@@ -15,8 +18,6 @@
if (urlParams.has("key")) {
apiKeyStorage.set(urlParams.get("key")!);
}
let activeChatId: number;
</script>
<Navbar />
@@ -25,14 +26,12 @@
<div class="container is-fullhd">
<div class="columns">
<div class="column is-one-fifth">
<Sidebar bind:apiKey bind:sortedChats bind:activeChatId />
<Sidebar bind:apiKey bind:sortedChats />
</div>
<div class="column is-four-fifths">
{#if activeChatId}
<Chat bind:chatId={activeChatId} />
{:else}
<Home bind:activeChatId />
{/if}
{#key $location}
<Router {routes}/>
{/key}
</div>
</div>
</div>