import Link from 'next/link'; import { FaYoutube } from 'react-icons/fa6'; import { DataListArticleVideo } from '@/data/article/ListAricleVideo'; import Image from 'next/image'; import useFancybox from '@/hooks/useFancybox'; export const BoxVideoArticle = () => { const getYoutubeEmbedUrl = (url: string): string => { try { const urlObj = new URL(url); // nếu là link youtube dạng watch?v=... if (urlObj.hostname.includes('youtube.com')) { const videoId = urlObj.searchParams.get('v'); if (videoId) { return `https://www.youtube.com/embed/${videoId}?autoplay=1`; } } // nếu là link youtu.be/xxxx if (urlObj.hostname.includes('youtu.be')) { const videoId = urlObj.pathname.replace('/', ''); if (videoId) { return `https://www.youtube.com/embed/${videoId}?autoplay=1`; } } // fallback: trả về chính url return url; } catch { return url; } }; const [fancyboxRef] = useFancybox({ closeButton: 'auto', dragToClose: true, }); return (
Youtube channel