import React, { useMemo } from "react"; import CardRenderer from "../Cards/CardRenderer"; import { cardTokens } from "../../theme/cardTokens"; function normTheme(t) { if (t === "dark" || t === "blue" || t === "light") return t; return "dark"; } export default function TemplateMarkerCard({ post, template, theme = "dark", mode = "full", // "mini" or "full" onOpenUrl, }) { const spec = mode === "mini" ? template?.mini_spec_json : template?.full_spec_json; const data = useMemo(() => { const rawImage = mode === "mini" ? (post?.image_small || post?.image_medium || post?.thumbnail_url || "") : (post?.image_medium || post?.image_large || post?.image_small || post?.image || post?.thumbnail_url || post?.media_url || ""); return { headline: post?.title || "Untitled", source: post?.source || (post?.author ? `by ${post.author}` : "") || (post?.sub_category || ""), summary: post?.snippet || post?.body || post?.content || "", url: post?.url || "", image: normalizeImageUrl(rawImage), }; }, [post]); if (!spec) { // fallback simple return (