import type { Metadata } from "next"; import Link from "next/link"; import { Container, SectionHeading } from "@/components/ui"; import { ScrollReveal } from "@/components/scroll-reveal"; import { ProductCard } from "@/components/product-card"; import { RecentlyViewedSection } from "@/components/recently-viewed-section"; import { getActiveProducts, type ProductSort } from "@/lib/data"; import { getReviewSummariesByProductIds } from "@/lib/reviews"; import { getSiteUrl } from "@/lib/url"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; import type { ProductCategory } from "@/generated/prisma/client"; export const metadata: Metadata = { title: "Shop", description: "Hochwertiger Honig, Bienenwachskerzen und Propolis aus eigener Imkerei in Altenmünster.", alternates: { canonical: "/shop" }, }; // Siehe Begruendung in app/page.tsx. export const dynamic = "force-dynamic"; function buildHref(params: { q?: string; kategorie?: string; sortierung?: string; verfuegbar?: string; }): string { const search = new URLSearchParams(); if (params.q) search.set("q", params.q); if (params.kategorie) search.set("kategorie", params.kategorie); if (params.sortierung) search.set("sortierung", params.sortierung); if (params.verfuegbar) search.set("verfuegbar", params.verfuegbar); const qs = search.toString(); return qs ? `/shop?${qs}` : "/shop"; } export default async function ShopPage(props: PageProps<"/shop">) { const t = getDictionary(await getLocale()); const categoryFilters = [ { value: undefined, label: t.shop.allCategories }, { value: "HONIG", label: t.common.categories.HONIG }, { value: "KERZEN", label: t.common.categories.KERZEN }, { value: "PROPOLIS", label: t.common.categories.PROPOLIS }, ] as const; const sortOptions: { value: ProductSort | ""; label: string }[] = [ { value: "", label: t.shop.sortNewest }, { value: "preis-auf", label: t.shop.sortPriceAsc }, { value: "preis-ab", label: t.shop.sortPriceDesc }, { value: "verfuegbarkeit", label: t.shop.sortAvailability }, ]; const { q, kategorie, sortierung, verfuegbar } = await props.searchParams; const query = typeof q === "string" ? q : undefined; const category = typeof kategorie === "string" && ["HONIG", "KERZEN", "PROPOLIS"].includes(kategorie) ? (kategorie as ProductCategory) : undefined; const sort = typeof sortierung === "string" && ["preis-auf", "preis-ab", "verfuegbarkeit"].includes(sortierung) ? (sortierung as ProductSort) : undefined; const onlyAvailable = verfuegbar === "1"; const products = await getActiveProducts({ query, category, sort, onlyAvailable }); const reviewSummaries = await getReviewSummariesByProductIds(products.map((p) => p.id)); const base = getSiteUrl(); const breadcrumbJsonLd = { "@context": "https://schema.org", "@type": "BreadcrumbList", itemListElement: [ { "@type": "ListItem", position: 1, name: "Start", item: base }, { "@type": "ListItem", position: 2, name: "Shop", item: `${base}/shop` }, ], }; return (
{t.shop.searchResults(query, products.length)}{" "} {t.shop.clearSearch}
) : null}{query ? t.shop.noSearchResults : t.shop.noProducts}
) : null}