Reworked user state and login

This commit is contained in:
2026-01-18 01:24:26 +02:00
parent 53aed96a05
commit dfbcaafb77
8 changed files with 106 additions and 30 deletions
+8
View File
@@ -0,0 +1,8 @@
---
const {href} = Astro.props
const isActive = Astro.url.pathname.startsWith(href)
---
<a class:list={[{active: isActive}]} href={href}>
<slot></slot>
</a>
+21
View File
@@ -0,0 +1,21 @@
<script setup>
import {useStore} from '@nanostores/vue'
import {$user} from "../stores/user.js";
const user = useStore($user)
</script>
<template>
<div v-if="!user.initialized" class="placeholder"></div> <!-- TODO: replace with an actual placeholder -->
<a href="/login" v-else-if="!user.loggedIn">Login</a>
<span v-else>{{ user.username || "Username" }}</span>
</template>
<style scoped>
.placeholder {
display: inline-block;
width: 2em;
height: 1em;
background: gray;
}
</style>