'use client'; import Link from 'next/link'; import { FaYoutube } from 'react-icons/fa6'; import Image from 'next/image'; import useFancybox from '@/hooks/useFancybox'; import { getArticleVideos } from '@/lib/api/article'; import { useApiData } from '@/hooks/useApiData'; import type { ListArticle } from '@/types/article/TypeListArticle'; export const BoxVideoArticle = () => { const { data: videos } = useApiData( () => getArticleVideos(), [], { initialData: [] as ListArticle }, ); const getYoutubeEmbedUrl = (url: string): string => { try { const urlObj = new URL(url); if (urlObj.hostname.includes('youtube.com')) { const videoId = urlObj.searchParams.get('v'); if (videoId) { return `https://www.youtube.com/embed/${videoId}?autoplay=1`; } } if (urlObj.hostname.includes('youtu.be')) { const videoId = urlObj.pathname.replace('/', ''); if (videoId) { return `https://www.youtube.com/embed/${videoId}?autoplay=1`; } } return url; } catch { return url; } }; const [fancyboxRef] = useFancybox({ closeButton: 'auto', dragToClose: true, }); return (
Youtube channel