"use client" import { useMemo } from "react" interface YouTubeEmbedProps { url: string title?: string } function extractVideoId(url: string): string | null { // Handle various YouTube URL formats const patterns = [ /(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&?/]+)/, /youtube\.com\/v\/([^&?/]+)/, /youtube\.com\/shorts\/([^&?/]+)/ ] for (const pattern of patterns) { const match = url.match(pattern) if (match && match[1]) { return match[1] } } return null } export function YouTubeEmbed({ url, title = "YouTube video" }: YouTubeEmbedProps) { const videoId = useMemo(() => extractVideoId(url), [url]) if (!videoId) { return null } return (