From 60a1e22392ae6c17d956c278a4bbe9e22d19c84d Mon Sep 17 00:00:00 2001 From: satnaing Date: Wed, 17 Jan 2024 15:24:02 +0630 Subject: [PATCH] fix: remove recent posts section if there's no post Changes made: - Removed the recent posts section if there are no posts under the recent section. - Eliminated unnecessary
tags when there are no recent posts. - Extracted all-links from the recent section. Closes: #204 --- src/pages/index.astro | 46 ++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/pages/index.astro b/src/pages/index.astro index bc752611f..82b74bc09 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -14,6 +14,7 @@ const posts = await getCollection("blog"); const sortedPosts = getSortedPosts(posts); const featuredPosts = sortedPosts.filter(({ data }) => data.featured); +const recentPosts = sortedPosts.filter(({ data }) => !data.featured); const socialCount = SOCIALS.filter(social => social.active).length; --- @@ -83,18 +84,17 @@ const socialCount = SOCIALS.filter(social => social.active).length; ))} -
+ {recentPosts.length > 0 &&
} ) } -
-

Recent Posts

- +
+ ) + } + +
+ + All Posts + + + +