--- import { Icon } from 'astro-icon/components'; import { twMerge } from 'tailwind-merge'; import type { Item } from '~/types'; export interface Props { items?: Array; defaultIcon?: string; classes?: Record; compact?: boolean; } const { items = [], classes = {}, defaultIcon, compact = false } = Astro.props as Props; const { container: containerClass = '', panel: panelClass = '', title: titleClass = '', description: descriptionClass = '', icon: defaultIconClass = 'text-primary dark:text-slate-200 border-primary dark:border-blue-700', timeline: timelineClass = 'bg-primary/30 dark:bg-blue-700/30', timelineDot: timelineDotClass = 'bg-primary dark:bg-blue-700', year: yearClass = 'text-primary dark:text-blue-300', } = classes; --- { items && items.length && (
{/* Main timeline line */}
{items.map((item, index) => { const { title, description, icon, classes: itemClasses = {} } = item; const isEven = index % 2 === 0; // Use the year property if available, otherwise try to extract from date let year = item.year; // If year is not provided, try to extract from date in the description if (!year && description) { // Look for a date pattern like MM-YYYY const dateMatch = description.match(/\d{2}-(\d{4})/); if (dateMatch) { year = dateMatch[1]; } } return (
{/* Year marker (if available) */} {year && (
{year}
)} {/* Timeline dot */}
{/* Content card */}
{(icon || defaultIcon) && ( )} {title &&

}

{description && (
)}
{/* Connector line to timeline (visible only on desktop) */}
); })}
) }