diff --git a/src/lib/block-types.ts b/src/lib/block-types.ts index da6f721..39962d2 100644 --- a/src/lib/block-types.ts +++ b/src/lib/block-types.ts @@ -168,6 +168,18 @@ export interface YoutubeVideoBlockData { layout?: BlockLayout; } +/** Galerie aus YouTube-Video-Referenzen (_type: "youtube_video_gallery"). */ +export interface YoutubeVideoGalleryBlockData { + _type?: "youtube_video_gallery"; + _slug?: string; + title?: string; + subtitle?: string; + description?: string; + variant?: "carousel" | "grid"; + videos?: YoutubeVideoBlockData[]; + layout?: BlockLayout; +} + /** Zitat (_type: "quote"). */ export interface QuoteBlockData { _type?: "quote"; diff --git a/src/lib/components/ContentRows.svelte b/src/lib/components/ContentRows.svelte index 5f9538b..ca7418f 100644 --- a/src/lib/components/ContentRows.svelte +++ b/src/lib/components/ContentRows.svelte @@ -7,6 +7,7 @@ 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"; @@ -30,6 +31,7 @@ ImageGalleryBlockData, FilesBlockData, YoutubeVideoBlockData, + YoutubeVideoGalleryBlockData, QuoteBlockData, QuoteCarouselBlockData, LinkListBlockData, @@ -118,6 +120,8 @@ {:else if blockType(item) === "youtube_video"} + {:else if blockType(item) === "youtube_video_gallery"} + {:else if blockType(item) === "quote"} {:else if blockType(item) === "quote_carousel"} diff --git a/src/lib/components/blocks/YoutubeVideoGalleryBlock.svelte b/src/lib/components/blocks/YoutubeVideoGalleryBlock.svelte new file mode 100644 index 0000000..7496454 --- /dev/null +++ b/src/lib/components/blocks/YoutubeVideoGalleryBlock.svelte @@ -0,0 +1,377 @@ + + + + +
+ {#if block.title} +

{block.title}

+ {/if} + {#if block.subtitle} +

{block.subtitle}

+ {/if} + {#if descriptionHtml} +
+ {@html descriptionHtml} +
+ {/if} + + {#if items.length === 0} +

{t(T.youtube_missing)}

+ {:else if block.variant === "grid"} +
    + {#each items as item, i} + {@const label = (item.video.title ?? "").trim()} +
  • + +
  • + {/each} +
+ + {#if modalOpen} + {@const cur = items[modalIndex]} + {@const curLabel = (cur.video.title ?? "").trim()} + + {/if} + {:else} + {@const second = items.length > 1 ? items[(currentIndex + 1) % items.length] : null} +
+
+
+ {#key currentIndex} + {@const current = items[currentIndex]} +
+ +
+ {#if second} + + {/if} + {/key} +
+ + {#if items.length > 1} + + + {/if} +
+ + {#key currentIndex} + {@const current = items[currentIndex]} +
+
+ {#if current.video.title} +

{current.video.title}

+ {/if} + {#if current.video.description} +
{@html renderMd(current.video.description)}
+ {/if} +
+ {#if second} + + {/if} +
+ {/key} + + {#if items.length > 1} + +
+ {#each items as _, i} + + {/each} +
+ {/if} +
+ {/if} +