mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix: remove recent posts section if there's no post (#238)
Changes made: - Removed the recent posts section if there's no post under the recent section. - Eliminated unnecessary <Hr /> tags when there's no recent post. - Extracted all-links from the recent section and put it above the footer. Closes: #204
This commit is contained in:
+24
-22
@@ -14,6 +14,7 @@ const posts = await getCollection("blog");
|
|||||||
|
|
||||||
const sortedPosts = getSortedPosts(posts);
|
const sortedPosts = getSortedPosts(posts);
|
||||||
const featuredPosts = sortedPosts.filter(({ data }) => data.featured);
|
const featuredPosts = sortedPosts.filter(({ data }) => data.featured);
|
||||||
|
const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
|
||||||
|
|
||||||
const socialCount = SOCIALS.filter(social => social.active).length;
|
const socialCount = SOCIALS.filter(social => social.active).length;
|
||||||
---
|
---
|
||||||
@@ -83,18 +84,17 @@ const socialCount = SOCIALS.filter(social => social.active).length;
|
|||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
<Hr />
|
{recentPosts.length > 0 && <Hr />}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
<section id="recent-posts">
|
{
|
||||||
<h2>Recent Posts</h2>
|
recentPosts.length > 0 && (
|
||||||
<ul>
|
<section id="recent-posts">
|
||||||
{
|
<h2>Recent Posts</h2>
|
||||||
sortedPosts
|
<ul>
|
||||||
.filter(({ data }) => !data.featured)
|
{recentPosts.map(
|
||||||
.map(
|
|
||||||
({ data, slug }, index) =>
|
({ data, slug }, index) =>
|
||||||
index < 4 && (
|
index < 4 && (
|
||||||
<Card
|
<Card
|
||||||
@@ -103,20 +103,22 @@ const socialCount = SOCIALS.filter(social => social.active).length;
|
|||||||
secHeading={false}
|
secHeading={false}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
)
|
)}
|
||||||
}
|
</ul>
|
||||||
</ul>
|
</section>
|
||||||
<div class="all-posts-btn-wrapper">
|
)
|
||||||
<LinkButton href="/posts">
|
}
|
||||||
All Posts
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg"
|
<div class="all-posts-btn-wrapper">
|
||||||
><path
|
<LinkButton href="/posts">
|
||||||
d="m11.293 17.293 1.414 1.414L19.414 12l-6.707-6.707-1.414 1.414L15.586 11H6v2h9.586z"
|
All Posts
|
||||||
></path>
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
</svg>
|
><path
|
||||||
</LinkButton>
|
d="m11.293 17.293 1.414 1.414L19.414 12l-6.707-6.707-1.414 1.414L15.586 11H6v2h9.586z"
|
||||||
</div>
|
></path>
|
||||||
</section>
|
</svg>
|
||||||
|
</LinkButton>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<Footer />
|
<Footer />
|
||||||
|
|||||||
Reference in New Issue
Block a user