From 5b1648bf82220968912ea40cc8132a44f623f5bd Mon Sep 17 00:00:00 2001 From: Peter Meier Date: Thu, 9 Apr 2026 14:39:43 +0200 Subject: [PATCH] Enhance component functionality and styling across the project - Updated .gitignore to include raw image files for better asset management. - Added optional icon and color properties to Tag and TagItem interfaces for improved tag customization. - Enhanced BlogOverview and PostCard components to support new tag features, including icon and color display. - Refined Card component to accept target and rel attributes for better link handling. - Improved layout responsiveness in ContentRows and PostCard components. - Updated OrganisationsBlock to include a new CTA link feature for adding organizations. - Enhanced QuoteBlock styling for better visual emphasis on quotes. - Refactored image handling in various components to ensure consistent display and performance. - Introduced utility functions for resolving body content and filtering hidden posts in blog utilities. --- .gitignore | 1 + src/components/BlogOverview.svelte | 6 +- src/components/Card.svelte | 18 ++- src/components/ContentRows.svelte | 9 +- src/components/PostCard.svelte | 34 +++--- src/components/Tag.svelte | 109 +++++++++++++++--- src/components/Tags.svelte | 28 ++++- src/components/blocks/OpnFormBlock.svelte | 68 +++++++---- .../blocks/OrganisationsBlock.svelte | 51 ++++++-- src/components/blocks/QuoteBlock.svelte | 6 +- src/lib/block-types.ts | 2 + src/lib/blog-utils.ts | 102 +++++++++++----- src/lib/cms-api.generated.ts | 34 +++++- src/lib/rusty-image.ts | 16 +++ src/pages/post/[slug].astro | 14 +-- src/pages/posts/index.astro | 17 ++- src/pages/posts/page/[page].astro | 18 ++- src/pages/posts/tag/[tag].astro | 18 ++- src/pages/posts/tag/[tag]/page/[page].astro | 18 ++- src/styles/global.css | 2 +- 20 files changed, 440 insertions(+), 131 deletions(-) diff --git a/.gitignore b/.gitignore index ea52020..e41e8ec 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ pnpm-debug.log* .firebase/ .history/ public/images/transformed/ +public/images/raw/ public/pagefind \ No newline at end of file diff --git a/src/components/BlogOverview.svelte b/src/components/BlogOverview.svelte index 472ab54..ad1611c 100644 --- a/src/components/BlogOverview.svelte +++ b/src/components/BlogOverview.svelte @@ -10,6 +10,8 @@ interface TagEntry { _slug?: string; name: string; + icon?: string; + color?: string; } let { @@ -62,6 +64,8 @@ href={tagHref(slug)} variant={activeTag === slug ? "inactive" : "green"} active={activeTag === slug} + icon={tag.icon?.trim() || null} + customColor={activeTag === slug ? null : tag.color?.trim() || null} /> {/each} @@ -75,7 +79,7 @@ activeTag={activeTag} /> -
+
{#each posts as post} {#if href} - + {@render children?.()} {:else} diff --git a/src/components/ContentRows.svelte b/src/components/ContentRows.svelte index 1dc2021..1165904 100644 --- a/src/components/ContentRows.svelte +++ b/src/components/ContentRows.svelte @@ -95,6 +95,7 @@ > {#each row.content as item} {#if isResolvedBlock(item)} + {@const rowBlockType = blockType(item)} {#snippet blockContent()} {#if blockType(item) === "markdown"} @@ -132,8 +133,12 @@ {/snippet} {#if isBlockLayoutBreakout((item as { layout?: BlockLayout }).layout)}
-
-
+
+
{@render blockContent()}
diff --git a/src/components/PostCard.svelte b/src/components/PostCard.svelte index fcb3dc9..3e5ad9a 100644 --- a/src/components/PostCard.svelte +++ b/src/components/PostCard.svelte @@ -15,23 +15,29 @@ } = $props(); const resolvedImg = $derived(post._resolvedImageUrl); - const bgStyle = $derived(resolvedImg ? `background-image: url(${resolvedImg})` : ""); - {#if resolvedImg} - - {/if} -
+
+ {#if resolvedImg} + {post.headline + {:else} +
+ +
+ {/if} +
+
{#if post.subheadline} -
+
{post.subheadline}
{/if} {#if post.excerpt} -

+

{post.excerpt}

{/if} diff --git a/src/components/Tag.svelte b/src/components/Tag.svelte index 8c06669..f2f03be 100644 --- a/src/components/Tag.svelte +++ b/src/components/Tag.svelte @@ -1,4 +1,7 @@ {#if href} -
{label} + + {#if icon} + {:else if onclick} - + {:else} - {label} + + {#if icon} + {/if} diff --git a/src/components/Tags.svelte b/src/components/Tags.svelte index b4f5f7d..c7ac3c2 100644 --- a/src/components/Tags.svelte +++ b/src/components/Tags.svelte @@ -1,7 +1,9 @@ @@ -32,6 +52,8 @@ label={name} variant={variant} href={tagBase ? `${tagBase}/${slug(t)}` : null} + icon={tagIcon(t)} + customColor={tagColor(t)} /> {/if} {/each} diff --git a/src/components/blocks/OpnFormBlock.svelte b/src/components/blocks/OpnFormBlock.svelte index e80c4ec..b436e3a 100644 --- a/src/components/blocks/OpnFormBlock.svelte +++ b/src/components/blocks/OpnFormBlock.svelte @@ -13,25 +13,41 @@ : "https://opnform.pm86.de" ).replace(/\/$/, ""), ); - const iframeSrc = $derived( - formId ? `${baseUrl}/forms/${formId}` : "", - ); - const iframeTitle = $derived( - block.iframeTitle?.trim() || "Kontaktformular", - ); + const iframeSrc = $derived(formId ? `${baseUrl}/forms/${formId}` : ""); + const iframeTitle = $derived(block.iframeTitle?.trim() || "Kontaktformular"); - /** - * Wie im OpnForm-Embed: initEmbed erst wenn iframe.min.js fertig geladen ist - * (entspricht
{#if iframeSrc}