From 3e08328a8da9dd517b02fac7dc4634a63a8be34e Mon Sep 17 00:00:00 2001 From: nakajmg Date: Thu, 21 Dec 2023 15:41:15 +0900 Subject: [PATCH] fix timeline sorting --- src/pages/lookback/[slug].astro | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/lookback/[slug].astro b/src/pages/lookback/[slug].astro index 0c7fd26b..e2a907d9 100644 --- a/src/pages/lookback/[slug].astro +++ b/src/pages/lookback/[slug].astro @@ -37,7 +37,11 @@ const createTopicsByMonth = (topics: Topic[]): TopicByMonth[] => { topicsByMonth[monthIndex].topics.push(topic) } }) - return topicsByMonth + return topicsByMonth.sort((a, b) => { + if (a.month > b.month) return 1 + if (a.month < b.month) return -1 + return 0 + }) } const sortByDate = (topics: TopicByMonth[]): TopicByMonth[] => {