fix(post-overview): hide block entirely when no posts + no intro text
Deploy / verify (push) Successful in 38s
Deploy / deploy (push) Successful in 59s

The post_overview block kept rendering its <h3> headline + the
"all posts" footer link even when both `postsResolved` was empty
and `text` was unset, leaving a heading with nothing under it on
pages like /mediathek that include the block defensively.

Wrap the whole render in `{#if hasContent}` so empty overviews
disappear; the heading reappears as soon as posts or intro text
are present.
This commit is contained in:
Peter Meier
2026-04-25 10:54:05 +02:00
parent 998fba8904
commit 9eab404240
@@ -20,8 +20,13 @@
const posts = $derived((block.postsResolved ?? []) as (PostEntry & { _resolvedImageUrl?: string })[]); const posts = $derived((block.postsResolved ?? []) as (PostEntry & { _resolvedImageUrl?: string })[]);
const design = $derived(block.design || "cards"); const design = $derived(block.design || "cards");
const tagBase = "/posts/tag"; const tagBase = "/posts/tag";
// Hide the entire block (headline, intro, footer link) when there are no
// posts and no intro text — otherwise an empty section with just a heading
// sits on the page.
const hasContent = $derived(posts.length > 0 || textHtml.length > 0);
</script> </script>
{#if hasContent}
<div <div
class="post-overview mb-4 {layoutClasses} {className}" class="post-overview mb-4 {layoutClasses} {className}"
data-block-type="post_overview" data-block-type="post_overview"
@@ -57,3 +62,4 @@
</div> </div>
{/if} {/if}
</div> </div>
{/if}