Files
windwiderstand/src/lib/components/BlockRenderer.svelte
T
Peter Meier 7bd62b75b0
Deploy / verify (push) Successful in 1m8s
Deploy / deploy (push) Successful in 1m13s
feat(contacts): ContactCard + ContactsBlock-Komponente, BlockRenderer registriert
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-04 08:49:23 +02:00

122 lines
5.1 KiB
Svelte

<script lang="ts">
import MarkdownBlock from "./blocks/MarkdownBlock.svelte";
import HeadlineBlock from "./blocks/HeadlineBlock.svelte";
import HtmlBlock from "./blocks/HtmlBlock.svelte";
import IframeBlock from "./blocks/IframeBlock.svelte";
import ImageBlock from "./blocks/ImageBlock.svelte";
import ImageGalleryBlock from "./blocks/ImageGalleryBlock.svelte";
import FilesBlock from "./blocks/FilesBlock.svelte";
import YoutubeVideoBlock from "./blocks/YoutubeVideoBlock.svelte";
import YoutubeVideoGalleryBlock from "./blocks/YoutubeVideoGalleryBlock.svelte";
import QuoteBlock from "./blocks/QuoteBlock.svelte";
import QuoteCarouselBlock from "./blocks/QuoteCarouselBlock.svelte";
import LinkListBlock from "./blocks/LinkListBlock.svelte";
import PostOverviewBlock from "./blocks/PostOverviewBlock.svelte";
import SearchableTextBlock from "./blocks/SearchableTextBlock.svelte";
import CalendarBlock from "./blocks/CalendarBlock.svelte";
import CalendarCompactBlock from "./blocks/CalendarCompactBlock.svelte";
import OrganisationsBlock from "./blocks/OrganisationsBlock.svelte";
import ContactsBlock from "./blocks/ContactsBlock.svelte";
import OpnFormBlock from "./blocks/OpnFormBlock.svelte";
import InternalComponentBlock from "./blocks/InternalComponentBlock.svelte";
import DeadlineBannerBlock from "./blocks/DeadlineBannerBlock.svelte";
import WindkarteBlock from "./blocks/WindkarteBlock.svelte";
import type { Translations } from "$lib/translations";
import type {
ResolvedBlock,
MarkdownBlockData,
HeadlineBlockData,
HtmlBlockData,
IframeBlockData,
ImageBlockData,
ImageGalleryBlockData,
FilesBlockData,
YoutubeVideoBlockData,
YoutubeVideoGalleryBlockData,
QuoteBlockData,
QuoteCarouselBlockData,
LinkListBlockData,
PostOverviewBlockData,
SearchableTextBlockData,
CalendarBlockData,
OrganisationsBlockData,
ContactsBlockData,
OpnFormBlockData,
InternalComponentBlockData,
DeadlineBannerBlockData,
LiveStrommixBlockData,
WindMapBlockData,
StellingnahmeGeneratorBlockData,
} from "$lib/block-types";
let {
block,
translations = {},
}: { block: ResolvedBlock; translations?: Translations | null } = $props();
const type = $derived((block._type as string) ?? "unknown");
</script>
{#if type === "markdown"}
<MarkdownBlock block={block as MarkdownBlockData} />
{:else if type === "headline"}
<HeadlineBlock block={block as HeadlineBlockData} />
{:else if type === "html"}
<HtmlBlock block={block as HtmlBlockData} />
{:else if type === "iframe"}
<IframeBlock block={block as IframeBlockData} translations={translations} />
{:else if type === "image"}
<ImageBlock block={block as ImageBlockData} />
{:else if type === "image_gallery"}
<ImageGalleryBlock block={block as ImageGalleryBlockData} />
{:else if type === "files"}
<FilesBlock block={block as FilesBlockData} />
{:else if type === "youtube_video"}
<YoutubeVideoBlock block={block as YoutubeVideoBlockData} />
{:else if type === "youtube_video_gallery"}
<YoutubeVideoGalleryBlock block={block as YoutubeVideoGalleryBlockData} />
{:else if type === "quote"}
<QuoteBlock block={block as QuoteBlockData} />
{:else if type === "quote_carousel"}
<QuoteCarouselBlock block={block as QuoteCarouselBlockData} />
{:else if type === "link_list"}
<LinkListBlock block={block as LinkListBlockData} />
{:else if type === "post_overview"}
<PostOverviewBlock block={block as PostOverviewBlockData} />
{:else if type === "searchable_text"}
<SearchableTextBlock block={block as SearchableTextBlockData} translations={translations} />
{:else if type === "calendar"}
{#if (block as CalendarBlockData).variant === "compact"}
<CalendarCompactBlock block={block as CalendarBlockData} translations={translations} />
{:else}
<CalendarBlock block={block as CalendarBlockData} translations={translations} />
{/if}
{:else if type === "organisations"}
<OrganisationsBlock block={block as OrganisationsBlockData} />
{:else if type === "contacts_block"}
<ContactsBlock block={block as ContactsBlockData} />
{:else if type === "opnform"}
<OpnFormBlock block={block as OpnFormBlockData} />
{:else if type === "internal_component"}
<InternalComponentBlock block={block as InternalComponentBlockData} />
{:else if type === "deadline_banner"}
<DeadlineBannerBlock block={block as DeadlineBannerBlockData} />
{:else if type === "live_strommix"}
<!-- Lazy: ~220 KB Block-Bundle nur laden wenn Seite das Widget tatsächlich hat -->
{#await import("./blocks/StrommixBlock.svelte") then m}
{@const Comp = m.default}
<Comp block={block as LiveStrommixBlockData} />
{/await}
{:else if type === "wind_map"}
<WindkarteBlock block={block as WindMapBlockData} />
{:else if type === "stellungnahme_generator"}
{#await import("./blocks/StellingnahmeGeneratorBlock.svelte") then m}
{@const Comp = m.default}
<Comp block={block as StellingnahmeGeneratorBlockData} />
{/await}
{:else}
<div class="rounded border border-erde-200 bg-erde-50 px-3 py-2 text-sm text-erde-800">
Unbekannter Block: <code>{type}</code>
</div>
{/if}