stuff
This commit is contained in:
parent
14f8e77e6a
commit
a2f001392b
11 changed files with 241 additions and 2 deletions
13
Foxnouns.Frontend/src/routes/+layout.server.ts
Normal file
13
Foxnouns.Frontend/src/routes/+layout.server.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import type Meta from "$lib/api/meta";
|
||||
import type { User } from "$lib/api/user";
|
||||
import request from "$lib/request";
|
||||
|
||||
export async function load({ fetch }) {
|
||||
const meta = await request<Meta>(fetch, "GET", "/meta");
|
||||
let user: User | undefined;
|
||||
try {
|
||||
user = await request<User>(fetch, "GET", "/users/@me");
|
||||
} catch {}
|
||||
|
||||
return { meta, user };
|
||||
}
|
11
Foxnouns.Frontend/src/routes/+layout.svelte
Normal file
11
Foxnouns.Frontend/src/routes/+layout.svelte
Normal file
|
@ -0,0 +1,11 @@
|
|||
<script lang="ts">
|
||||
import Navbar from "$lib/nav/Navbar.svelte";
|
||||
import "bootstrap/dist/css/bootstrap.min.css";
|
||||
import type { LayoutData } from "./$types";
|
||||
|
||||
export let data: LayoutData;
|
||||
</script>
|
||||
|
||||
<Navbar user={data.user} />
|
||||
|
||||
<slot />
|
|
@ -1,2 +1,19 @@
|
|||
<script lang="ts">
|
||||
import type { PageData } from "./$types";
|
||||
export let data: PageData;
|
||||
</script>
|
||||
|
||||
<h1>Welcome to SvelteKit</h1>
|
||||
<p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>
|
||||
|
||||
<p>
|
||||
are you logged in? {data.user !== undefined}
|
||||
{#if data.user}
|
||||
<br />hello, {data.user.username}!
|
||||
<br />your ID: {data.user.id}
|
||||
{/if}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
stats: {data.meta.users.total} users, {data.meta.members} members
|
||||
</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue