import type { Metadata } from 'next'; import VideosPage from "../../components/VideosPage"; import { getPageMetadata } from "../../lib/seo"; import { generateVideoObjectSchema, generateBreadcrumbSchema } from "../../lib/schema"; export async function generateMetadata(): Promise { return getPageMetadata('videos', { canonicalPath: '/videos', fallbackTitle: 'ویدئوهای آموزشی و توصیه‌های بالینی دامپزشکان', fallbackDesc: 'مشاهده ویدئوهای تخصصی نحوه مصرف مکمل‌های درمانی، نظرات دامپزشکان و راهکارهای بالینی تصویری کنینا آلمان.', }); } async function getInitialVideos() { const apiUrl = process.env.INTERNAL_API_URL || process.env.NEXT_PUBLIC_API_URL || 'http://localhost:4001/api'; const apiBase = apiUrl.endsWith('/api') ? apiUrl : `${apiUrl.replace(/\/$/, '')}/api`; try { const res = await fetch(`${apiBase}/videos?limit=20`, { next: { revalidate: 3600, tags: ['videos'] }, }); if (!res.ok) return []; const data = await res.json(); return Array.isArray(data) ? data : Array.isArray(data.data) ? data.data : []; } catch (e) { console.error('[Videos] Error fetching server videos for schema:', e); return []; } } export default async function Videos() { const videos = await getInitialVideos(); const videoSchemas = videos.map((v: any) => generateVideoObjectSchema({ name: v.title || 'ویدیو آموزشی کنینا', description: v.description || `آموزش و توصیه‌های تخصصی دامپزشکی درباره مصرف مکمل‌های درمانی کنینا توسط ${v.doctor || 'متخصصین کنینا'}.`, thumbnailUrl: v.coverUrl || v.thumbnail || 'https://canina.ir/assets/images/logo.png', uploadDate: v.createdAt || '2025-01-01T00:00:00Z', contentUrl: v.videoUrl || undefined, embedUrl: v.videoUrl || undefined, }) ); const breadcrumbs = generateBreadcrumbSchema([ { name: 'صفحه اصلی', url: 'https://canina.ir' }, { name: 'آکادمی ویدیوها', url: 'https://canina.ir/videos' }, ]); const itemListSchema = { '@context': 'https://schema.org', '@type': 'ItemList', itemListElement: videoSchemas.map((vSchema: any, idx: number) => ({ '@type': 'ListItem', position: idx + 1, item: vSchema, })), }; return ( <> {videoSchemas.length > 0 && (