Monorepo for Tangled
Something went wrong. Try again.
Svelte
1234567891011121314151617181920212223242526272829303132333435363738<script module lang="ts"> import { tv } from "tailwind-variants";
export const refChip = tv({ base: "flex w-fit items-center justify-center gap-2xs whitespace-nowrap" });</script>
<script lang="ts"> import { resolve } from "$app/paths";
interface Props { ownerHandle: string; repoName: string; ref: string; class?: string; }
let { ownerHandle, repoName, ref, class: className = "" }: Props = $props();
const isCommit = $derived(/^[0-9a-f]{7,40}$/.test(ref)); const label = $derived(isCommit ? ref.slice(0, 8) : ref); const description = $derived(isCommit ? `commit ${label}` : label);
const treeHref = $derived( resolve(`/${ownerHandle}/${repoName}/tree/${encodeURIComponent(ref)}` as "/") );</script>
<div class={refChip({ class: className })}> <span class="text-foreground-muted">at{isCommit ? " commit" : ""}</span> <a href={treeHref} aria-label="Browse {description}" class="text-foreground-default no-underline hover:underline">{label}</a ></div>