diff --git a/src/lib/block-types.ts b/src/lib/block-types.ts index 71b2bc0..752ff5e 100644 --- a/src/lib/block-types.ts +++ b/src/lib/block-types.ts @@ -420,6 +420,12 @@ export type CalendarBlockData = Omit< /** Slugs oder aufgelöste calendar_item-Einträge. */ items?: (string | CalendarItemData)[]; layout?: BlockLayout; + /** Variante: "default" voller Kalender, "compact" Anteaser. */ + variant?: "default" | "compact"; + /** Compact: Ziel-Page-Referenz hinter dem "Alle Termine"-Link. */ + linkTo?: string | { _slug?: string;[key: string]: unknown }; + /** Compact: Anzahl Termine (default 3). */ + limit?: number; }; /** Internal component block (_type: "internal_component"). */ diff --git a/src/lib/components/BlockRenderer.svelte b/src/lib/components/BlockRenderer.svelte index e5117a8..4c05a3a 100644 --- a/src/lib/components/BlockRenderer.svelte +++ b/src/lib/components/BlockRenderer.svelte @@ -14,6 +14,7 @@ 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 OpnFormBlock from "./blocks/OpnFormBlock.svelte"; import InternalComponentBlock from "./blocks/InternalComponentBlock.svelte"; @@ -82,7 +83,11 @@ {:else if type === "searchable_text"} {:else if type === "calendar"} - + {#if (block as CalendarBlockData).variant === "compact"} + + {:else} + + {/if} {:else if type === "organisations"} {:else if type === "opnform"} diff --git a/src/lib/components/blocks/CalendarCompactBlock.svelte b/src/lib/components/blocks/CalendarCompactBlock.svelte new file mode 100644 index 0000000..f89e7b9 --- /dev/null +++ b/src/lib/components/blocks/CalendarCompactBlock.svelte @@ -0,0 +1,118 @@ + + +
+
+
+ + {#if upcoming.length === 0} +

+ {t(T.calendar_no_future_events)} +

+ {:else} +
    + {#each upcoming as { it, start } (it._slug ?? it.title)} + {@const timeStr = fmtTime(start)} +
  • +
    + + {start.toLocaleDateString("de-DE", { month: "short" }).replace(".", "")} + + + {start.getDate()} + +
    +
    +

    {it.title ?? t(T.calendar_untitled)}

    +

    + {fmtDate(start)}{timeStr ? ` · ${timeStr}` : ""} + {#if it.location} + · {typeof it.location === "string" ? it.location : (it.location as { text?: string })?.text ?? ""} + {/if} +

    +
    +
  • + {/each} +
+ {/if} + + {#if linkHref()} + + {t(T.calendar_all_upcoming)} + + {/if} +