import { Link } from 'react-router-dom' import { MONTH_LABELS, type PersonRef, type TimelineItem } from '../../../lib/timeline.ts' import { hrefFor, logoSrc } from '../../../lib/timelineRefs.ts' import { initials, mediaUrl } from '../../../lib/media.ts' const KIND_NAMES: Record = { milestone: 'Milestone', event: 'Event', organization: 'Organization', award: 'Award', people: 'People', } /** Day number only, the month node above already carries the month. */ function dayMarker(item: TimelineItem): string { if (item.precision !== 'day') return '' const day = Number(item.date.split('-')[2]) return Number.isFinite(day) ? String(day) : '' } /** Featured entries sit above the month nodes, so they spell out their date. */ function fullMarker(item: TimelineItem): string { const [, m, d] = item.date.split('-') if (item.precision === 'year' || !m) return 'Date unrecorded' const month = MONTH_LABELS[Number(m) - 1] ?? '' if (item.precision === 'month' || !d) return month return `${month} ${Number(d)}` } function PersonChip({ person }: { person: PersonRef }) { const src = mediaUrl(person.photo) return (
  • {src ? ( ) : ( )} {person.name} {person.title ? ( {person.title} ) : null}
  • ) } type Props = { item: TimelineItem /** Featured entries render larger and lead the year. */ variant?: 'inline' | 'featured' } export default function TimelineEntry({ item, variant = 'inline' }: Props) { const featured = variant === 'featured' const href = hrefFor(item) const logo = logoSrc(item) const className = [ 'ngu-tl__entry', featured ? 'ngu-tl__entry--featured' : '', href ? 'ngu-tl__entry--linked' : '', ] .filter(Boolean) .join(' ') const marker = ( {featured ? fullMarker(item) : dayMarker(item)} ) const body = ( {logo ? ( ) : ( {item.meta ? {item.meta} : null} {item.blurb ?

    {item.blurb}

    : null}
    ) // The people list sits outside the link: each name is its own // destination, and nesting anchors is invalid markup anyway. const roster = item.kind === 'people' && item.people && item.people.length > 0 ? (
    {item.team ? ( {item.team.name} {item.team.orgName ? ` ยท ${item.team.orgName}` : ''} ) : null}
      {item.people.map((person) => ( ))}
    ) : null const label = `${KIND_NAMES[item.kind]}: ${item.title}` // An explicit href may point off-site; Link is for in-app routes only. const external = !!href && /^(https?:)?\/\//.test(href) return (
  • {href && external ? ( {marker} {body} ) : href ? ( {marker} {body} ) : (
    {marker} {body}
    )} {roster}
  • ) }