Update internal server options and enhance layout logic for user-specific routes. Changed version hash and added pathname tracking to conditionally render user menu based on site routes.
This commit is contained in:
@@ -2,18 +2,32 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { enhance } from '$app/forms';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { get } from 'svelte/store';
|
||||
import { onMount } from 'svelte';
|
||||
import './layout.css';
|
||||
import * as Avatar from '$lib/components/ui/avatar';
|
||||
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
|
||||
import { Label } from '$lib/components/ui/label';
|
||||
import { Switch } from '$lib/components/ui/switch';
|
||||
import { siteSlugs } from '$lib/sites';
|
||||
|
||||
let { data, children }: {
|
||||
data: { user: { id: string; email?: string; name?: string; avatar?: string; darkmode: boolean } | null };
|
||||
children: import('svelte').Snippet;
|
||||
} = $props();
|
||||
|
||||
let pathname = $state(get(page).url.pathname);
|
||||
$effect(() => {
|
||||
const unsub = page.subscribe((p) => {
|
||||
pathname = p.url.pathname;
|
||||
});
|
||||
return unsub;
|
||||
});
|
||||
const isSiteRoute = $derived(
|
||||
(siteSlugs as readonly string[]).includes(pathname.slice(1).split('/')[0] ?? '')
|
||||
);
|
||||
|
||||
let darkmode = $state(false);
|
||||
let onDarkmodeChange: (checked: boolean) => void = () => {};
|
||||
|
||||
@@ -45,7 +59,7 @@
|
||||
</script>
|
||||
|
||||
<div class="app-shell">
|
||||
{#if data.user}
|
||||
{#if data.user && !isSiteRoute}
|
||||
<header
|
||||
class="fixed right-0 top-0 z-50 flex items-center gap-2 p-2 pr-[max(0.5rem,env(safe-area-inset-right))] pt-[max(0.5rem,env(safe-area-inset-top))]"
|
||||
aria-label="User menu"
|
||||
|
||||
Reference in New Issue
Block a user