fix: show the title only if the list has items

This commit is contained in:
KazooTTT
2025-02-14 19:01:57 +08:00
parent 3af73ab320
commit 6639493f18
2 changed files with 11 additions and 7 deletions

View File

@ -18,7 +18,7 @@ const { as: Tag = "div", post, withDesc = false } = Astro.props;
<Tag>
{post.data.draft && <span class="text-red-500">(Draft) </span>}
<a class="cactus-link" data-astro-prefetch href={`/posts/${post.id}/`}>
{post.data.fixedToTop && <span class="text-accent-2">*</span>}
{post.data.fixedToTop && <span class="text-accent-2 mr-2">*</span>}
{post.data.title}
</a>
</Tag>

View File

@ -33,6 +33,8 @@ const latestNotes = allNotes.sort(collectionDateSort).slice(0, MAX_NOTES);
<SocialList />
</section>
{
allFixedToTopPostsByDate.length > 0 && (
<section class="mt-16">
<h2 class="title text-accent mb-6 text-xl"><a href="/posts/">置顶文章</a></h2>
<ul class="space-y-4" role="list">
@ -45,6 +47,8 @@ const latestNotes = allNotes.sort(collectionDateSort).slice(0, MAX_NOTES);
}
</ul>
</section>
)
}
<section class="mt-16">
<h2 class="title text-accent mb-6 text-xl"><a href="/posts/">Posts</a></h2>