Skip to content

Commit

Permalink
fix upcoming event banner not being sorted 🐛 #233
Browse files Browse the repository at this point in the history
  • Loading branch information
Freymaurer committed Dec 3, 2024
1 parent 1071ee7 commit c0980d7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/events/NextEventBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CollectionEntry } from 'astro:content';
import { InlineIcon } from '@iconify/react/dist/iconify.js';
import { reducePeriodicEvents, formatterDate } from '~/util/EventUtil';
import { reducePeriodicEvents, formatterDate, type ReducedEvent } from '~/util/EventUtil';

interface Props {
events: CollectionEntry<'events'>[];
Expand All @@ -9,7 +9,10 @@ interface Props {
export default function UpcomingEventBanner({events}: Props) {
const reducedEvents = reducePeriodicEvents(events);
//only future events
const upcomingEvents = reducedEvents.filter((event) => event.data.when.start > new Date());
const upcomingEvents =
reducedEvents
.filter((event) => event.data.when.start > new Date())
.sort((a: ReducedEvent, b: ReducedEvent) => b.data.when.start.getTime() - a.data.when.start.getTime());
const nextEvent = upcomingEvents[upcomingEvents.length - 1];
if (!nextEvent) {
return null;
Expand Down

0 comments on commit c0980d7

Please sign in to comment.