Something went wrong. Try again.
Monorepo for Tangled
Something went wrong. Try again.
Svelte
1234567891011121314151617181920212223242526272829303132333435363738394041424344<script lang="ts"> import { resolve } from "$app/paths"; import FilePathChip from "$lib/components/repo/FilePathChip.svelte"; import { encodePathSegments } from "$lib/components/repo/urls";
interface Props { ownerHandle: string; repoName: string; ref: string; // repo-relative path, empty at the tree root path: string; }
let { ownerHandle, repoName, ref, path }: Props = $props();
const treeBase = $derived(`/${ownerHandle}/${repoName}/tree/${encodeURIComponent(ref)}`);
const crumbs = $derived.by(() => { const parts = path.split("/").filter(Boolean); return [ { name: repoName, href: treeBase, last: parts.length === 0 }, ...parts.map((name, index) => ({ name, href: `${treeBase}/${encodePathSegments(parts.slice(0, index + 1).join("/"))}`, last: index === parts.length - 1 })) ]; });</script>
<FilePathChip> {#each crumbs as crumb (crumb.href)} {#if crumb.last} <span class="text-foreground-default" aria-current="page">{crumb.name}</span> {:else} <a href={resolve(crumb.href as "/")} class="text-foreground-muted no-underline hover:underline">{crumb.name}</a > <span class="text-foreground-muted" aria-hidden="true">/</span> {/if} {/each}</FilePathChip>