--- /* --------------------------------------------------------------------------- * Internal cell renderer for ResourceListView. * * One Column kind per branch. Branches must stay exhaustive over Column * — if a new kind is added to resource-types.ts, TypeScript will warn here * via the `never` fallback. * ------------------------------------------------------------------------- */ import { relativeTime } from '../../lib/format'; import type { Column } from '../resource-types'; interface Props { column: Column>; item: Record; } const { column, item } = Astro.props; const kind = column.kind ?? 'text'; // Text column — default rendering ───────────────────────────────────────── let textTitle: string | null = null; let textSubtitle: string | null = null; if (kind === 'text') { const col = column as Extract; if (col.render) { const r = col.render(item); textTitle = r.title; textSubtitle = r.subtitle ?? null; } else { const v = item[column.key]; textTitle = v == null ? '' : String(v); } } // Pill column ───────────────────────────────────────────────────────────── let pillLabel: string | null = null; let pillClass: string | null = null; if (kind === 'pill') { const col = column as Extract; const raw = col.value ? col.value(item) : (item[column.key] as string | undefined); if (raw) { const variant = col.pillVariants[raw]; if (variant) { pillLabel = variant.label; pillClass = variant.class; } else { pillLabel = raw; pillClass = 'pill-draft'; // graceful fallback } } } // Relative-date column ──────────────────────────────────────────────────── let relText: string | null = null; let relEmpty: string | null = null; if (kind === 'relative-date') { const col = column as Extract; const raw = col.value ? col.value(item) : (item[column.key] as string | null | undefined); if (raw) { relText = relativeTime(raw); } else { relEmpty = col.emptyFallback ?? '—'; } } // Number column ─────────────────────────────────────────────────────────── let numberText: string | null = null; if (kind === 'number') { const col = column as Extract; const raw = col.value ? col.value(item) : (item[column.key] as number | null | undefined); numberText = raw == null ? '—' : String(raw); } // Tag-list column ───────────────────────────────────────────────────────── let tags: string[] = []; if (kind === 'tag-list') { const col = column as Extract; tags = col.value(item); } --- {kind === 'text' && (
{textTitle} {textSubtitle && {textSubtitle}}
)} {kind === 'pill' && ( pillLabel ? {pillLabel} : )} {kind === 'relative-date' && ( relText ? {relText} : {relEmpty} )} {kind === 'number' && ( {numberText} )} {kind === 'tag-list' && ( tags.length > 0 ?
    {tags.map(t =>
  • {t}
  • )}
: )}