diff --git a/src/components/EventItem.astro b/src/components/EventItem.astro index cf0623d..f53af0b 100644 --- a/src/components/EventItem.astro +++ b/src/components/EventItem.astro @@ -1,8 +1,11 @@ --- const { item } = Astro.props; -import { format, compareAsc, addDays } from 'date-fns'; +import { format, compareAsc, addDays, isFuture } from 'date-fns'; import { marked } from 'marked'; +const isDate = item.date.match(/^\d{4}-\d{2}-\d{2}$/) +const future = isDate && !isFuture(new Date(item.date)); + function dateFormat (str) { if (str.match(/^\d{4}-\d{2}-\d{2}$/)) { return format(new Date(str), 'MMM d, yyyy') @@ -56,10 +59,16 @@ const statuses = { confirmed: { title: 'Confirmed', color: 'text-green-500', + }, + past: { + title: 'Already happened', + color: 'text-green-800', } } -const status = item.confirmed ? statuses.confirmed : (item.links?.rsvp ? statuses.preregistration : statuses.unconfirmed) +const status = item.confirmed + ? (future ? statuses.past : statuses.confirmed) + : (item.links?.rsvp ? statuses.preregistration : statuses.unconfirmed); --- @@ -73,7 +82,14 @@ const status = item.confirmed ? statuses.confirmed : (item.links?.rsvp ? statuse }