'use client'; import Link from 'next/link'; import Image from 'next/image'; import { useState } from 'react'; interface VideoData { id: string; title: string; uploader: string; channel_id?: string; thumbnail: string; view_count: number; duration: string; uploaded_date?: string; list_id?: string; is_mix?: boolean; } function formatViews(views: number): string { if (views >= 1000000) return (views / 1000000).toFixed(1) + 'M'; if (views >= 1000) return (views / 1000).toFixed(1) + 'K'; return views.toString(); } function getRelativeTime(id: string): string { const times = ['2 hours ago', '5 hours ago', '1 day ago', '3 days ago', '1 week ago', '2 weeks ago', '1 month ago']; const index = (id.charCodeAt(0) || 0) % times.length; return times[index]; } import { memo } from 'react'; function VideoCard({ video, hideChannelAvatar }: { video: VideoData; hideChannelAvatar?: boolean }) { const relativeTime = video.uploaded_date || getRelativeTime(video.id); const [isNavigating, setIsNavigating] = useState(false); const destination = video.list_id ? `/watch?v=${video.id}&list=${video.list_id}` : `/watch?v=${video.id}`; return (
setIsNavigating(true)} style={{ position: 'relative', display: 'block', width: '100%', aspectRatio: '16/9', overflow: 'hidden', borderRadius: '12px' }} > {video.title} {video.duration && !video.is_mix && (
{video.duration}
)} {video.is_mix && (
Mix
)} {isNavigating && (
)}
{/* Video Info */}

{video.title}

{video.channel_id ? ( {video.uploader} ) : (
{video.uploader}
)}
{formatViews(video.view_count)} views • {relativeTime}
); } export default memo(VideoCard);