Brijesh's Git Server — catalyst @ master

client/src/routes/+layout.svelte (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
<script lang="ts">
	import '../app.css';
	import Sidebar from '../components/Sidebar.svelte';
	import { onMount } from 'svelte';
	import { page } from '$app/stores';
	import { writable } from 'svelte/store';

	let { children } = $props();
	const showSidebar = writable<boolean>(false);
	const nonDashboardRoutes = ['/login'];

	onMount(() => {
		const unsubscribe = page.subscribe(($page) => {
			showSidebar.set(!nonDashboardRoutes.some((route) => $page.url.pathname.startsWith(route)));
		});
		return () => unsubscribe();
	});
</script>

{#if $showSidebar}
	<main class="flex">
		<Sidebar />
		<div class="flex-1">
			{@render children()}
		</div>
	</main>
{:else}
	{@render children()}
{/if}