From 77ed75a699961b83cb5f579e0672bc0d95345ff7 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 2 Aug 2023 23:30:00 +0100 Subject: [PATCH] fix(talks): order future talks in reverse Show the nearest upcoming talk first. --- src/pages/talks/index.astro | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/pages/talks/index.astro b/src/pages/talks/index.astro index 4e3e2b6e..b203b2cb 100644 --- a/src/pages/talks/index.astro +++ b/src/pages/talks/index.astro @@ -22,9 +22,16 @@ const sortedTalks = talks b.item.data.events[b.item.data.events.length - 1], ]; - return ( - new Date(events[0].date).valueOf() - new Date(events[1].date).valueOf() - ); + const dates = [ + new Date(events[0].date).valueOf(), + new Date(events[1].date).valueOf(), + ]; + + if (dates[0] >= today) { + return 1; + } + + return dates[0] - dates[1]; }); ---