import { TimelineEvent } from '../data/timelineEvents'
import Link from './Link'
const dateFormat = (date: string) => {
const parsedDate = new Date(date)
return Intl
? new Intl.DateTimeFormat('sv-SE', {
month: 'long',
year: 'numeric',
}).format(parsedDate)
: `${parsedDate.getFullYear()}-${parsedDate.getMonth()}`
}
interface TimelineProps {
events: TimelineEvent[]
}
const Timeline = ({ events }: TimelineProps): JSX.Element => {
return (
{events.map(({ date, media, importantDates, overview }) => (
-
{dateFormat(date)}
{dateFormat(date)}
{overview}
{importantDates.length > 0 && (
Viktiga händelser
{importantDates.map((important, i) => (
-
{important.link ? (
{important.description}
) : (
important.description
)}
{important.date}
))}
)}
{media.length > 0 && (
Media
{media.map((m) => (
-
{m.link ? (
{m.description}
) : (
m.description
)}
{m.date}
))}
)}
))}
)
}
export default Timeline