import type { Metadata } from 'next'; import { Button } from '@/components/ui/button'; import Link from 'next/link'; import { ExternalLink } from 'lucide-react'; export const metadata: Metadata = { title: "Dadvocate Vids - A curated collection of videos from The Dadvocate", description: "A curated collection of videos from The Dadvocate.", }; interface Video { id: string; title: string; } // Placeholder video IDs - these can be replaced with actual Dadvocate video IDs. const videoIds = [ 'dbPXoZ_cri8', 'y2SfYffLZQ4', 'CdJLCln1Kjg', 'e6rHHtq5K1k', 'GbWJfWhkOhc', 'pzefTg9jygs', 'zp3PRgtBOl0', 'XZA6c5Gg7NA', ]; // Updated fallback data to be a reliable source of working videos. const fallbackData: Video[] = [ { id: 'dbPXoZ_cri8', title: 'Placeholder Dadvocate Video 1' }, { id: 'y2SfYffLZQ4', title: 'Placeholder Dadvocate Video 2' }, ]; async function getYouTubeVideos(ids: string[]): Promise { const apiKey = process.env.YOUTUBE_API_KEY; if (!apiKey) { console.warn("YOUTUBE_API_KEY environment variable not set. Using hardcoded video titles as fallback."); return fallbackData; } const url = `https://www.googleapis.com/youtube/v3/videos?part=snippet&id=${ids.join(',')}&key=${apiKey}`; try { const response = await fetch(url, { next: { revalidate: 3600 } }); // Revalidate every hour if (!response.ok) { const errorData = await response.json(); console.error("YouTube API Error:", errorData.error.message); console.log("Falling back to hardcoded video data."); return fallbackData; } const data = await response.json(); if (!data.items || data.items.length === 0) { console.warn("YouTube API returned no items for the given video IDs. Falling back to hardcoded data."); return fallbackData; } interface YouTubeVideoItem { id: string; snippet: { title: string; }; } const fetchedVideos = data.items.map((item: YouTubeVideoItem) => ({ id: item.id, title: item.snippet.title, })); if (fetchedVideos.length < ids.length) { console.warn(`YouTube API only returned ${fetchedVideos.length} videos out of ${ids.length} requested. Some videos may be private or deleted.`); } return fetchedVideos; } catch (error) { console.error("Failed to fetch from YouTube API:", error); console.log("Falling back to hardcoded video data."); return fallbackData; } } export default async function DadvocatePage() { const videos = await getYouTubeVideos(videoIds); return (

Dadvocate Vids

A curated collection of videos from The Dadvocate

{videos.length > 0 ? videos.map((video) => (
{/* 16:9 Aspect Ratio */}

{video.title}

Watch on YouTube
)) : (

Could not load videos. Please try again later.

)}
); }