--- import Layout from "../../layouts/Layout.astro"; import AddToCartButton from "../../components/AddToCartButton.astro"; import { getProductByHandle, getDefaultRegion } from "../../lib/medusa"; import { formatEUR, formatGrundpreis } from "../../lib/format"; export const prerender = false; const { handle } = Astro.params; const region = await getDefaultRegion(); const product = handle ? await getProductByHandle(handle, region.id) : null; if (!product) { return Astro.redirect("/shop"); } const infoByVariant = Object.fromEntries( product.variants.map((variant) => [ variant.id, { price: variant.calculated_price ? formatEUR(variant.calculated_price.calculated_amount) : "", grundpreis: variant.calculated_price && variant.metadata?.net_weight_grams ? formatGrundpreis(variant.calculated_price.calculated_amount, variant.metadata.net_weight_grams) : null, }, ]) ); const initial = infoByVariant[product.variants[0]?.id] ?? { price: "", grundpreis: null }; const deliveryTime = product.metadata?.delivery_time; const gallery = (product.images?.length ? product.images.map((i) => i.url) : product.thumbnail ? [product.thumbnail] : []); ---
{gallery[0] && {product.title}}
{gallery.length > 1 && (
{gallery.map((url, index) => ( ))}
)}
{product.metadata?.category && (

{product.metadata.category}

)}

{product.title}

{initial.price}

inkl. MwSt.

{initial.grundpreis ?? ""}

{product.description}

{deliveryTime && (

Lieferzeit: {deliveryTime}

)}

Regional aus Hamburg

Nachhaltig produziert