Skip to content

Commit

Permalink
feat: update featured section logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jinhojang6 committed Apr 2, 2024
1 parent 93047e9 commit b11e591
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/containers/HomePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ export const HomePage: React.FC<HomePageProps> = ({
}
}

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 (
<Root {...props}>
<HeroContainer>
Expand All @@ -75,7 +86,7 @@ export const HomePage: React.FC<HomePageProps> = ({
<FeaturedFirst>
<PostsGrid
shows={shows}
posts={highlighted.slice(0, 1)}
posts={[firstFeaturedPost]}
pattern={[{ cols: 1, size: 'large' }]}
breakpoints={[
{
Expand All @@ -92,7 +103,7 @@ export const HomePage: React.FC<HomePageProps> = ({
<FeaturedSecond>
<PostsGrid
shows={shows}
posts={[highlighted[1], highlighted[2]]}
posts={secondFeaturedPosts}
pattern={[{ cols: 2, size: 'large' }]}
breakpoints={[
{
Expand Down

0 comments on commit b11e591

Please sign in to comment.