import React from 'react'; /** * Extracts YouTube video ID from various URL formats * Supports: * - https://www.youtube.com/watch?v=VIDEO_ID * - https://youtu.be/VIDEO_ID * - https://www.youtube.com/embed/VIDEO_ID * - Direct VIDEO_ID */ function extractVideoId(url) { if (!url) return null; // If it's already just an ID (no URL) if (!url.includes('http') && !url.includes('youtube') && !url.includes('youtu.be')) { return url; } // Extract from various YouTube URL formats const patterns = [ /(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&\n?#]+)/, /^([a-zA-Z0-9_-]{11})$/ // Direct ID ]; for (const pattern of patterns) { const match = url.match(pattern); if (match && match[1]) { return match[1]; } } return null; } export default function YouTubeEmbed({ url, title = 'Project walkthrough video' }) { const videoId = extractVideoId(url); if (!videoId) { return null; } const embedUrl = `https://www.youtube.com/embed/${videoId}?rel=0&modestbranding=1`; return (

Walkthrough Video