Preserve originating views through detail navigation

This commit is contained in:
2026-10-05 19:02:18 -04:00
parent b926d46616
commit 056fbd7517
25 changed files with 189 additions and 48 deletions
@@ -1,4 +1,6 @@
<script lang="ts">
import { page } from '$app/stores';
import { navigationLocation } from '$lib/navigation.js';
interface Crumb {
label: string;
href?: string | null;
@@ -9,18 +11,20 @@
}
let { items }: Props = $props();
const group = $derived(navigationLocation($page.url.pathname, $page.data.user?.role ?? 'viewer')?.group);
const trail = $derived(group && group.label !== items[0]?.label ? [{ label: group.label }, ...items] : items);
</script>
<nav class="crumbs" aria-label="Breadcrumb">
<ol>
{#each items as c, i (i + c.label)}
{#each trail as c, i (i + c.label)}
<li>
{#if c.href && i < items.length - 1}
{#if c.href && i < trail.length - 1}
<a href={c.href}>{c.label}</a>
{:else}
<span aria-current={i === items.length - 1 ? 'page' : undefined}>{c.label}</span>
<span aria-current={i === trail.length - 1 ? 'page' : undefined}>{c.label}</span>
{/if}
{#if i < items.length - 1}<span class="sep" aria-hidden="true">›</span>{/if}
{#if i < trail.length - 1}<span class="sep" aria-hidden="true">›</span>{/if}
</li>
{/each}
</ol>