From ec00a8537dec188e2d153d0d665852e962f0530b Mon Sep 17 00:00:00 2001 From: Adam Lamers Date: Thu, 2 Apr 2026 15:13:43 -0400 Subject: [PATCH] youtube shorts embed --- src/chat/components/RichText.svelte | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/chat/components/RichText.svelte b/src/chat/components/RichText.svelte index cce5766..1f179c1 100644 --- a/src/chat/components/RichText.svelte +++ b/src/chat/components/RichText.svelte @@ -4,7 +4,7 @@ const urlRegex = /(https?:\/\/[^\s]+)/g; const parts = $derived(text.split(urlRegex)); - type EmbedType = "youtube" | "twitch" | "kick" | "image" | "link"; + type EmbedType = "youtube" | "youtube-shorts" | "twitch" | "kick" | "image" | "link"; interface EmbedData { type: EmbedType; url: string; @@ -23,6 +23,12 @@ continue; } + const ytShortsMatch = url.match(/(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/); + if (ytShortsMatch) { + results.push({ type: "youtube-shorts", url, videoId: ytShortsMatch[1] }); + continue; + } + const ytMatch = url.match( /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, ); @@ -65,6 +71,7 @@ const DEFAULT_COLLAPSED_STATES: Record = { image: false, youtube: true, + "youtube-shorts": false, twitch: true, kick: true, link: false, @@ -124,6 +131,8 @@
{#if embed.type === 'youtube'} YouTube + {:else if embed.type === 'youtube-shorts'} + YouTube Shorts {:else if embed.type === 'twitch'} Twitch {:else if embed.type === 'kick'} @@ -164,6 +173,19 @@ class="media-iframe" >
+ {:else if embed.type === "youtube-shorts"} +
+ +
{:else if embed.type === "twitch"}