import { ImageResponse } from "next/og"; import { getProductBySlug } from "@/lib/data"; import { formatPrice } from "@/lib/format"; export const alt = "Wabenhain Produkt"; export const size = { width: 1200, height: 630 }; export const contentType = "image/png"; /** * Produktspezifisches Social-Preview-Bild statt des generischen * Seiten-Fallbacks (app/opengraph-image.tsx) — wer einen Honig-Link teilt, * soll den tatsaechlichen Produktnamen und Preis in der Vorschau sehen statt * nur des Wabenhain-Markenbilds. */ export default async function Image({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const product = await getProductBySlug(slug); const title = product?.name ?? "Wabenhain"; const tags = product?.tasteTags.slice(0, 3).join(" · ") ?? ""; const price = product ? formatPrice(product.priceCents, product.currency) : ""; return new ImageResponse( (
WABENHAIN
{title}
{tags ? (
{tags}
) : null} {price ? (
{price}
) : null}
), { ...size } ); }