import type { ChangeType } from '~/lib/changelog-repo' import { CHANGE_TYPE_DISPLAY, changelogTagFilterUrl, changelogTypeFilterUrl, type ChangelogTimelineIndexItem, } from '~/lib/changelog.utils' import dayjs from 'dayjs' import { GitCommit } from 'lucide-react' import Link from 'next/link' import { type MouseEvent } from 'react' import { Badge, cn } from 'ui' import { ChangelogInlineMarkdown } from '@/components/Changelog/ChangelogInlineMarkdown' function groupChangelogIndexByYear( items: ChangelogTimelineIndexItem[] ): [number, ChangelogTimelineIndexItem[]][] { const map = new Map() for (const item of items) { const y = dayjs(item.sortDate).year() if (!map.has(y)) map.set(y, []) map.get(y)!.push(item) } return [...map.entries()].sort((a, b) => b[0] - a[0]) } export function ChangeTypeBadge({ type, onBadgeClick, className, }: { type: ChangeType onBadgeClick?: (e: MouseEvent) => void className?: string }) { const { label, badgeVariant } = CHANGE_TYPE_DISPLAY[type] return ( {label} ) } export function ProductBadges({ products, onBadgeClick, tiny, className, }: { products: string[] onBadgeClick?: (e: MouseEvent) => void tiny?: boolean className?: string }) { if (products.length === 0) return null return (
{products.map((product) => ( {product} ))}
) } function TimelineRow({ item, href }: { item: ChangelogTimelineIndexItem; href: string }) { const dateLabel = dayjs(item.sortDate).format('MMM D') return (
e.stopPropagation()} />

{item.title}

{item.summary && (

{item.summary}

)}
e.stopPropagation()} /> e.stopPropagation()} />
) } type Props = { items: ChangelogTimelineIndexItem[] omitOuterTimelineBorder?: boolean } export function ChangelogTimelineList(props: Props) { const { items, omitOuterTimelineBorder } = props const yearGroups = groupChangelogIndexByYear(items) return (
{yearGroups.map(([year, yearItems], yearIndex) => (
{year}
{year}
{yearItems.map((item) => ( ))}
))}
) }