diff --git a/components/buying-guide/BuyingGuideProductClient.tsx b/components/buying-guide/BuyingGuideProductClient.tsx index 91e2699c..550d95f8 100644 --- a/components/buying-guide/BuyingGuideProductClient.tsx +++ b/components/buying-guide/BuyingGuideProductClient.tsx @@ -5,7 +5,8 @@ import { useSearchParams, useRouter } from "next/navigation"; import ReactMarkdown from "react-markdown"; const API_URL = process.env.NEXT_PUBLIC_API_BASE_URL!; -const ASSET_URL = process.env.NEXT_PUBLIC_ASSET_URL!; +const ASSET_BASE = +process.env.NEXT_PUBLIC_ASSET_URL || "https://forms.lasereverything.net"; type Score = { id: string | number; cat: string; value: number | string; body?: string }; type LinkItem = { id?: string | number; text?: string; url: string; target?: string }; @@ -21,7 +22,7 @@ type Entry = { rec_text?: string; updates?: string; video_review_url?: string; - header?: { id?: string }; + header?: { id?: string; filename_disk?: string }; date_updated?: string | number; links?: LinkItem[]; scores?: Score[]; @@ -45,7 +46,7 @@ export default function BuyingGuideProductClient() { setError(null); try { const res = await fetch( - `${API_URL}/items/bg_entries/${productId}?fields=*,links.id,links.text,links.url,links.target,scores.id,scores.cat,scores.value,scores.body,header.id,date_updated`, + `${API_URL}/items/bg_entries/${productId}?fields=*,links.id,links.text,links.url,links.target,scores.id,scores.cat,scores.value,scores.body,header.id,header.filename_disk,date_updated`, { cache: "no-store" } ); if (!res.ok) throw new Error(await res.text()); @@ -69,9 +70,12 @@ export default function BuyingGuideProductClient() { return (sum / entry.scores.length).toFixed(1); }, [entry]); + // Prefer the public filename_disk path (like the list view). const headerUrl = - entry?.header?.id - ? `${ASSET_URL}/assets/${entry.header.id}?cache-buster=${entry.date_updated}&key=system-large-contain` + entry?.header?.filename_disk + ? `${ASSET_BASE}/assets/${entry.header.filename_disk}` + : entry?.header?.id + ? `${ASSET_BASE}/assets/${entry.header.id}?cache-buster=${entry.date_updated}&key=system-large-contain` : null; if (!productId) return null; // switcher guards this, but be defensive @@ -105,7 +109,11 @@ export default function BuyingGuideProductClient() { {/* Header Banner */} {headerUrl && (
- Header Image + Header Image
)} @@ -153,7 +161,9 @@ export default function BuyingGuideProductClient() { > {link.text || link.url} - {link.target && ({link.target})} + {link.target && ( + ({link.target}) + )} ))}