Add instant navigation from search results via TMDB IDs in URL

Navigate instantly to /titles/tmdb-{id}-{type} and show a skeleton
while the new /api/titles/resolve endpoint handles the full import
(TMDB fetch, availability, recommendations, colors). Existing titles
resolve in ~5ms; the URL is replaced with the UUID once resolved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 15:13:51 -05:00
co-authored by Claude Opus 4.6
parent 18385386d5
commit 081f53beac
9 changed files with 175 additions and 140 deletions
+1 -20
View File
@@ -1,8 +1,6 @@
"use client";
import { motion } from "motion/react";
import { useRouter } from "next/navigation";
import { useCallback } from "react";
import { TitleCard } from "@/components/title-card";
interface TitleRowItem {
@@ -36,23 +34,6 @@ const staggerItem = {
};
export function TitleRow({ heading, icon, items }: TitleRowProps) {
const router = useRouter();
const handleImport = useCallback(
async (tmdbId: number, type: "movie" | "tv") => {
const res = await fetch("/api/titles/import", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ tmdbId, type }),
});
const data = await res.json();
if (data.id) {
router.push(`/titles/${data.id}`);
}
},
[router],
);
if (items.length === 0) return null;
return (
@@ -80,7 +61,7 @@ export function TitleRow({ heading, icon, items }: TitleRowProps) {
posterPath={item.posterPath}
releaseDate={item.releaseDate}
voteAverage={item.voteAverage}
onImport={() => handleImport(item.tmdbId, item.type)}
href={`/titles/tmdb-${item.tmdbId}-${item.type}`}
/>
</motion.div>
))}