From 6639493f18483762876e1c03187b4669e37da8b7 Mon Sep 17 00:00:00 2001 From: KazooTTT Date: Fri, 14 Feb 2025 19:01:57 +0800 Subject: [PATCH] fix: show the title only if the list has items --- src/components/blog/PostPreview.astro | 2 +- src/pages/index.astro | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/blog/PostPreview.astro b/src/components/blog/PostPreview.astro index 41ef444..fe81513 100644 --- a/src/components/blog/PostPreview.astro +++ b/src/components/blog/PostPreview.astro @@ -18,7 +18,7 @@ const { as: Tag = "div", post, withDesc = false } = Astro.props; {post.data.draft && (Draft) } - {post.data.fixedToTop && *} + {post.data.fixedToTop && *} {post.data.title} diff --git a/src/pages/index.astro b/src/pages/index.astro index bfb7de6..a5af511 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -33,18 +33,22 @@ const latestNotes = allNotes.sort(collectionDateSort).slice(0, MAX_NOTES); -
-

置顶文章

-
    - { + { + allFixedToTopPostsByDate.length > 0 && ( +
    +

    置顶文章

    +
      + { allFixedToTopPostsByDate.map((p) => (
    • )) } -
    -
    +
+
+ ) + }

Posts