import type { ReactNode } from "react"; import { ExternalLink } from "lucide-react"; import { groupTimelineByDate, type TimelineItem, } from "@/lib/timelineBlocks"; import { timelineDayId } from "@/lib/toc"; type MdTimelineProps = { items: TimelineItem[]; /** 每项正文已渲染的 React 节点(与 items 等长);缺省则只显示纯文本 */ renderBody?: (item: TimelineItem, index: number) => ReactNode; }; const PREFIX_RE = /^(feat|fix|polish|chore|docs|refactor|style|perf|test)(?:\(([^)]*)\))?\s*:?\s*/i; function splitTitlePrefix(title: string): { kind?: string; scope?: string; rest: string } { const m = PREFIX_RE.exec(title); if (!m) return { rest: title }; const rest = title.slice(m[0].length).trim() || title; return { kind: m[1].toLowerCase(), scope: m[2]?.trim() || undefined, rest, }; } /** * 按日分组的垂直时间线(更新树)。 * 日分组 id 与 extractToc 的 tl-YYYY-MM-DD 对齐,供右侧目录跳转。 * 条目用普通段落而非 h3,避免被 .prose-content 标题样式放大。 */ export default function MdTimeline({ items, renderBody }: MdTimelineProps) { if (!items.length) { return
暂无时间线条目
; } const groups = groupTimelineByDate(items); let flat = 0; return (