import Link from 'next/link'; import Image from 'next/image'; import type { Metadata } from 'next'; import { fetchBrandBySlug, fetchProducts, formatPrice } from '@/lib/api'; import { formatRichText } from '@/lib/format-rich-text'; // Brand data comes from the live backend; resolve it at request time. export const dynamic = 'force-dynamic'; interface Props { params: Promise<{ slug: string }>; } export async function generateMetadata({ params }: Props): Promise { const { slug } = await params; const brand = await fetchBrandBySlug(slug); if (!brand) return { title: 'Marca no encontrada' }; return { title: brand.seoTitle ?? brand.name, description: brand.seoDescription ?? `Productos ${brand.name} en mercadodevida.`, }; } export default async function BrandPage({ params }: Props) { const { slug } = await params; const [brand, products] = await Promise.all([ fetchBrandBySlug(slug), fetchProducts({ brandSlug: slug, limit: 24 }), ]); if (!brand) { return (

Marca no encontrada

Ver todas las marcas →
); } return (
{/* Breadcrumb */} {/* Header */}
{brand.name.slice(0, 2).toUpperCase()}

{brand.name}

{brand.seoDescription && (

{brand.seoDescription}

)}

{products.length} producto{products.length !== 1 ? 's' : ''}

{/* Products */} {products.length === 0 ? (

No hay productos de esta marca todavía.

Ver otras marcas →
) : (
{products.map((product) => (
{product.images?.[0] ? ( {product.name} ) : ( 🌿 )}

{product.name}

{product.description && (
)}
{formatPrice(0)}
))}
)}
); }