Skip to content

Commit 4d224d7

Browse files
committed
Show [Show more] only if there are actually more items
1 parent 0487fac commit 4d224d7

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

packages/web/docs/src/app/blog/components/posts-by-tag/latest-posts.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,24 @@ export function LatestPosts({
4343
<ul className="mt-6 grid grid-cols-1 gap-4 sm:grid sm:grid-cols-2 sm:gap-6 md:mt-16 lg:grid-cols-3 xl:grid-cols-4">
4444
{firstSection}
4545
</ul>
46-
<details className="mt-8 sm:mt-12">
47-
<summary className="bg-beige-200 text-green-1000 border-beige-300 hover:bg-beige-300 hive-focus mx-auto w-fit cursor-pointer select-none list-none rounded-lg border px-4 py-2 hover:border-current dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:hover:bg-neutral-700 [&::marker]:hidden [[open]>&]:mb-8 [[open]>&]:sm:mb-12">
48-
<span className="[[open]_&]:hidden">Show more</span>
49-
<span className="hidden [[open]_&]:inline">Hide posts</span>
50-
</summary>
46+
{rest.length > 0 && (
47+
<details className="mt-8 sm:mt-12">
48+
<summary className="bg-beige-200 text-green-1000 border-beige-300 hover:bg-beige-300 hive-focus mx-auto w-fit cursor-pointer select-none list-none rounded-lg border px-4 py-2 hover:border-current dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100 dark:hover:bg-neutral-700 [&::marker]:hidden [[open]>&]:mb-8 [[open]>&]:sm:mb-12">
49+
<span className="[[open]_&]:hidden">Show more</span>
50+
<span className="hidden [[open]_&]:inline">Hide posts</span>
51+
</summary>
5152

52-
<ul className="mt-4 grid grid-cols-1 gap-4 sm:mt-6 sm:grid sm:grid-cols-2 sm:gap-6 lg:grid-cols-3 xl:grid-cols-4">
53-
{rest.map(post => {
54-
return (
55-
<li key={post.route} className="*:h-full">
56-
<BlogCard post={post} tag={tag} />
57-
</li>
58-
);
59-
})}
60-
</ul>
61-
</details>
53+
<ul className="mt-4 grid grid-cols-1 gap-4 sm:mt-6 sm:grid sm:grid-cols-2 sm:gap-6 lg:grid-cols-3 xl:grid-cols-4">
54+
{rest.map(post => {
55+
return (
56+
<li key={post.route} className="*:h-full">
57+
<BlogCard post={post} tag={tag} />
58+
</li>
59+
);
60+
})}
61+
</ul>
62+
</details>
63+
)}
6264
</section>
6365
);
6466
}

0 commit comments

Comments
 (0)