From 6f8b33761c5e6c247fa70083c3d9ce70d16b6397 Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Fri, 20 Dec 2024 15:44:40 +0100 Subject: [PATCH] Update page title retrieval logic --- frontend/src/routes/(app)/+layout.svelte | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/frontend/src/routes/(app)/+layout.svelte b/frontend/src/routes/(app)/+layout.svelte index 78f344d3d..df5522635 100644 --- a/frontend/src/routes/(app)/+layout.svelte +++ b/frontend/src/routes/(app)/+layout.svelte @@ -17,16 +17,18 @@ import commandPaletteOpen from '$lib/components/CommandPalette/CommandPalette.svelte'; let sidebarOpen = true; + function getPageTitle(): string { + return safeTranslate( + $page.data.title || $page.data.str || $page.data.name || $breadcrumbs.length > 1 + ? $breadcrumbs[$breadcrumbs.length - 1]?.label + : $page.url.pathname.split('/').pop() + ); + } + $: classesSidebarOpen = (open: boolean) => (open ? 'ml-7 lg:ml-64' : 'ml-7'); $: { - $pageTitle = safeTranslate( - $page.data.title || - $page.data.str || - $page.data.name || - $breadcrumbs[1]?.label || - $page.url.pathname.split('/').pop() - ); + $pageTitle = getPageTitle(); if ($breadcrumbs.length < 2) breadcrumbs.push([{ label: $pageTitle, href: $page.url.pathname }]); }