import { getTrending, Subject, TrendingResponse } from '@/lib/api'; import { getDracinRecommend, DramaboxItem } from '@/lib/dramabox'; import MovieCard from '@/components/MovieCard'; import Link from 'next/link'; export const revalidate = 3600; export default async function TrendingPage({ searchParams }: { searchParams: Promise<{ page?: string }> }) { const { page: pageParam } = await searchParams; const page = parseInt(pageParam || "1", 10); let trendingData: TrendingResponse = { subjectList: [], pager: { hasMore: false, nextPage: "1", page: "0", perPage: 0, totalCount: 0 } }; let dracinData: DramaboxItem[] = []; try { const [trendingRes, dracinRes] = await Promise.all([ getTrending(page), getDracinRecommend(page, 20) ]); trendingData = trendingRes; dracinData = dracinRes; } catch (e) { console.error("Failed to fetch trending:", e); } const { subjectList, pager } = trendingData; // Map Dracin Data to Subject const dracinSubjects: Subject[] = dracinData.map(d => ({ subjectId: d.id.toString(), subjectType: 3, title: d.name, description: d.introduction, releaseDate: "", genre: d.tags.join(", "), cover: { url: d.cover, width: 300, height: 450 }, image: { url: d.cover, width: 300, height: 450 }, countryName: "China", imdbRatingValue: "N/A", detailPath: `/dracin/${d.id}`, isDracin: true })); // Interleave or merge lists // Simple merge: [...subjectList, ...dracinSubjects] // Or interleave for better diversity const combinedList: Subject[] = []; const maxLength = Math.max(subjectList.length, dracinSubjects.length); for (let i = 0; i < maxLength; i++) { if (i < subjectList.length) combinedList.push(subjectList[i]); if (i < dracinSubjects.length) combinedList.push(dracinSubjects[i]); } return (