import authors from 'lib/authors.json' import Link from 'next/link' import React from 'react' import type Author from '~/types/author' import type PostTypes from '~/types/post' import dayjs from 'dayjs' import utc from 'dayjs/plugin/utc' import timezone from 'dayjs/plugin/timezone' import advancedFormat from 'dayjs/plugin/advancedFormat' import { Badge } from 'ui' dayjs.extend(utc) dayjs.extend(timezone) dayjs.extend(advancedFormat) interface Props { event: PostTypes } const EventListItem = ({ event }: Props) => { const authorArray: string[] | undefined = event?.author ? event.author.split(',') : [] const author = [] if (authorArray) { for (let i = 0; i < authorArray.length; i++) { author.push( authors.find((authors: Author) => { return authors.author_id === authorArray[i] }) ) } } return (

{event.title}

{event.categories && (
{event.categories.map( (category, i) => i === 0 && ( {category} ) )}
)} {event.date && }
) } const EventDate: React.FC<{ event: PostTypes }> = ({ event }) => { const parsedDate = dayjs.utc(event.date) /** * If meetups, show absolute time + timezone * otherwise show time based on timezone * */ const formattedDate = event.categories?.includes('meetup') ? parsedDate .tz('Europe/London') .format(`DD MMM YY, h${parsedDate.get('minutes') > 0 ? ':mmA' : 'A'}`) : parsedDate.tz(event.timezone).format(`DD MMM YY, h:mmA`) return (

{formattedDate} {parsedDate.tz(event.timezone).format(' z')}

) } export default EventListItem