From b11e591614bcea4cadc5c016b86e0d790f1d8a5c Mon Sep 17 00:00:00 2001 From: jinhojang6 Date: Tue, 2 Apr 2024 22:44:43 +0900 Subject: [PATCH] feat: update featured section logic --- src/containers/HomePage/HomePage.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/containers/HomePage/HomePage.tsx b/src/containers/HomePage/HomePage.tsx index 6e197d2..0683851 100644 --- a/src/containers/HomePage/HomePage.tsx +++ b/src/containers/HomePage/HomePage.tsx @@ -65,6 +65,17 @@ export const HomePage: React.FC = ({ } } + const firstFeaturedPost = + highlighted.sort( + (a, b) => + new Date(b.publishedAt as string).getTime() - + new Date(a.publishedAt as string).getTime(), + )[0] ?? highlighted[0] + + const secondFeaturedPosts = highlighted.filter( + (post) => post.id !== firstFeaturedPost?.id, + ) ?? [highlighted[1], highlighted[2]] + return ( @@ -75,7 +86,7 @@ export const HomePage: React.FC = ({ = ({