fix(post-overview): hide block entirely when no posts + no intro text
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:
@@ -20,8 +20,13 @@
|
||||
const posts = $derived((block.postsResolved ?? []) as (PostEntry & { _resolvedImageUrl?: string })[]);
|
||||
const design = $derived(block.design || "cards");
|
||||
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>
|
||||
|
||||
{#if hasContent}
|
||||
<div
|
||||
class="post-overview mb-4 {layoutClasses} {className}"
|
||||
data-block-type="post_overview"
|
||||
@@ -57,3 +62,4 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user