import { Play } from "lucide-react"; import { BookmarkTypes, ZBookmark } from "@karakeep/shared/types/bookmarks"; import { ContentRenderer } from "./types"; function extractYouTubeVideoId(url: string): string | null { const patterns = [ /(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&\n?#]+)/, /youtube\.com\/v\/([^&\n?#]+)/, /youtube\.com\/shorts\/([^&\n?#]+)/, ]; for (const pattern of patterns) { const match = url.match(pattern); if (match) { return match[1]; } } return null; } function canRenderYouTube(bookmark: ZBookmark): boolean { if (bookmark.content.type !== BookmarkTypes.LINK) { return false; } const url = bookmark.content.url; return extractYouTubeVideoId(url) !== null; } function YouTubeRendererComponent({ bookmark }: { bookmark: ZBookmark }) { if (bookmark.content.type !== BookmarkTypes.LINK) { return null; } const videoId = extractYouTubeVideoId(bookmark.content.url); if (!videoId) { return null; } const embedUrl = `https://www.youtube.com/embed/${videoId}`; return (