浏览代码

Merge branch 'worktree-agent-ae896a9c'

User 2 月之前
父节点
当前提交
54eab1a74f
共有 1 个文件被更改,包括 25 次插入1 次删除
  1. 25 1
      src/app/api/tmdb/reel-posters/route.ts

+ 25 - 1
src/app/api/tmdb/reel-posters/route.ts

@@ -2,6 +2,21 @@ import { NextResponse } from "next/server";
 import { REEL_POSTER_COUNT } from "@/lib/constants";
 import { fetchTMDBMovies } from "@/lib/tmdb-fetch";
 
+interface ReelPoster {
+  tmdb_id: number;
+  poster_path: string;
+  title: string;
+}
+
+// Always-pinned entries that lead the carousel.
+const PINNED_REEL_POSTERS: ReelPoster[] = [
+  {
+    tmdb_id: 615,
+    title: "The Passion of the Christ",
+    poster_path: "/rBM5o2HpmCfDejuIPybI09tkY3V.jpg",
+  },
+];
+
 // Fallback: fetch popular movies for reel posters.
 // In production, the cron job populates the landing_reel_posters table.
 export async function GET() {
@@ -18,12 +33,21 @@ export async function GET() {
       return NextResponse.json({ error }, { status: status ?? 502 });
     }
 
-    const posters = movies.slice(0, REEL_POSTER_COUNT).map((m) => ({
+    const popular: ReelPoster[] = movies.map((m) => ({
       tmdb_id: m.id,
       poster_path: m.poster_path!,
       title: m.title,
     }));
 
+    const seen = new Set<number>();
+    const posters: ReelPoster[] = [];
+    for (const p of [...PINNED_REEL_POSTERS, ...popular]) {
+      if (seen.has(p.tmdb_id)) continue;
+      seen.add(p.tmdb_id);
+      posters.push(p);
+      if (posters.length >= REEL_POSTER_COUNT) break;
+    }
+
     return NextResponse.json({ posters });
   } catch {
     return NextResponse.json({ error: "Internal server error" }, { status: 500 });