mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 05:05:38 -04:00
Refactor tmdbImageUrl to accept semantic category instead of size string
- Change primary argument from TMDB size string (`w500`, `w1280`, etc.) to category name (`posters`, `backdrops`, `stills`, `logos`, `profiles`); optional size override remains as third argument - Update all call sites across services, actions, pages, and route handlers to use the new category-based API - Update image.test.ts to match the new signature and replace size-mapping test descriptions with category-name descriptions
This commit is contained in:
@@ -13,18 +13,14 @@ export async function ContinueWatchingSection({ userId }: { userId: string }) {
|
||||
title: {
|
||||
id: item.title.id,
|
||||
title: item.title.title,
|
||||
backdropPath: tmdbImageUrl(item.title.backdropPath, "w1280"),
|
||||
backdropPath: tmdbImageUrl(item.title.backdropPath, "backdrops"),
|
||||
},
|
||||
nextEpisode: item.nextEpisode
|
||||
? {
|
||||
seasonNumber: item.nextEpisode.seasonNumber,
|
||||
episodeNumber: item.nextEpisode.episodeNumber,
|
||||
name: item.nextEpisode.name,
|
||||
stillPath: tmdbImageUrl(
|
||||
item.nextEpisode.stillPath,
|
||||
"w1280",
|
||||
"stills",
|
||||
),
|
||||
stillPath: tmdbImageUrl(item.nextEpisode.stillPath, "stills"),
|
||||
}
|
||||
: null,
|
||||
totalEpisodes: item.totalEpisodes,
|
||||
|
||||
@@ -13,7 +13,7 @@ export async function LibrarySection({ userId }: { userId: string }) {
|
||||
tmdbId: t.tmdbId,
|
||||
type: t.type,
|
||||
title: t.title,
|
||||
posterPath: tmdbImageUrl(t.posterPath, "w500"),
|
||||
posterPath: tmdbImageUrl(t.posterPath, "posters"),
|
||||
releaseDate: t.releaseDate ?? t.firstAirDate,
|
||||
voteAverage: t.voteAverage,
|
||||
userStatus: t.userStatus as "watchlist" | "in_progress" | "completed",
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function RecommendationsSection({ userId }: { userId: string }) {
|
||||
tmdbId: t.tmdbId,
|
||||
type: t.type,
|
||||
title: t.title,
|
||||
posterPath: tmdbImageUrl(t.posterPath, "w500"),
|
||||
posterPath: tmdbImageUrl(t.posterPath, "posters"),
|
||||
releaseDate: t.releaseDate ?? t.firstAirDate,
|
||||
voteAverage: t.voteAverage,
|
||||
}));
|
||||
|
||||
@@ -31,7 +31,7 @@ function mapResults(
|
||||
? r.media_type
|
||||
: fallbackType) as "movie" | "tv",
|
||||
title: r.title ?? r.name ?? "",
|
||||
posterPath: tmdbImageUrl(r.poster_path, "w500"),
|
||||
posterPath: tmdbImageUrl(r.poster_path, "posters"),
|
||||
releaseDate: r.release_date ?? r.first_air_date ?? null,
|
||||
voteAverage: r.vote_average,
|
||||
}));
|
||||
@@ -102,7 +102,7 @@ export default async function ExplorePage() {
|
||||
type={heroTitle.media_type as "movie" | "tv"}
|
||||
title={heroTitle.title ?? heroTitle.name ?? ""}
|
||||
overview={heroTitle.overview}
|
||||
backdropPath={tmdbImageUrl(heroTitle.backdrop_path, "w1280")}
|
||||
backdropPath={tmdbImageUrl(heroTitle.backdrop_path, "backdrops")}
|
||||
voteAverage={heroTitle.vote_average}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -42,7 +42,7 @@ export async function generateMetadata({
|
||||
openGraph: {
|
||||
title: title.title,
|
||||
images: title.posterPath
|
||||
? [{ url: tmdbImageUrl(title.posterPath, "w500") ?? "" }]
|
||||
? [{ url: tmdbImageUrl(title.posterPath, "posters") ?? "" }]
|
||||
: [],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ export async function GET(req: NextRequest) {
|
||||
tmdbId: r.id,
|
||||
type: "person" as const,
|
||||
title: r.name,
|
||||
profilePath: tmdbImageUrl(r.profile_path, "w185"),
|
||||
profilePath: tmdbImageUrl(r.profile_path, "profiles"),
|
||||
knownForDepartment: r.known_for_department,
|
||||
knownFor: r.known_for
|
||||
?.slice(0, 3)
|
||||
@@ -83,7 +83,7 @@ export async function GET(req: NextRequest) {
|
||||
type: "person" as const,
|
||||
title: r.name ?? "Unknown",
|
||||
posterPath: null,
|
||||
profilePath: tmdbImageUrl(r.profile_path ?? null, "w185"),
|
||||
profilePath: tmdbImageUrl(r.profile_path ?? null, "profiles"),
|
||||
overview: "",
|
||||
releaseDate: null,
|
||||
popularity: r.popularity,
|
||||
@@ -103,7 +103,7 @@ export async function GET(req: NextRequest) {
|
||||
title: r.title ?? r.name,
|
||||
overview: r.overview,
|
||||
releaseDate: r.release_date ?? r.first_air_date,
|
||||
posterPath: tmdbImageUrl(r.poster_path, "w500"),
|
||||
posterPath: tmdbImageUrl(r.poster_path, "posters"),
|
||||
popularity: r.popularity,
|
||||
voteAverage: r.vote_average,
|
||||
};
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ const posterPaths = [
|
||||
];
|
||||
|
||||
const posterUrls = posterPaths
|
||||
.map((p) => tmdbImageUrl(p, "w300"))
|
||||
.map((p) => tmdbImageUrl(p, "posters", "w300"))
|
||||
.filter(Boolean) as string[];
|
||||
|
||||
export default function Home() {
|
||||
|
||||
Reference in New Issue
Block a user