import { getTranslations, setRequestLocale } from 'next-intl/server' import { mockDb } from '@/lib/mockDb' import ListingCard from '@/components/ListingCard' import ListingsMapLoader from '@/components/ListingsMapLoader' import { Link } from '@/i18n/routing' import { notFound } from 'next/navigation' import { MapPin, SlidersHorizontal, Check } from 'lucide-react' import LiveFilterForm from '@/components/LiveFilterForm' import type { Metadata } from 'next' import { basicMetadata } from '@/lib/seo' interface PageProps { params: Promise<{ locale: string, category: string }> searchParams: Promise<{ search?: string neighborhood?: string price?: string approved?: string }> } export const dynamic = 'force-dynamic' export async function generateMetadata({ params }: PageProps): Promise { const { locale, category: categorySlug } = await params const categories = await mockDb.getCategories() const category = categories.find(c => c.slug === categorySlug) if (!category) return {} const name = locale === 'ru' ? category.nameRu : locale === 'en' ? category.nameEn : category.nameTr const title = locale === 'en' ? `${name} in Marmaris — Marmaris Local` : locale === 'ru' ? `${name} в Мармарисе — Marmaris Local` : `Marmaris ${name} Rehberi — Marmaris Local` const description = locale === 'en' ? `Browse the best ${name.toLowerCase()} in Marmaris, filtered by neighborhood and price — curated and locally approved.` : locale === 'ru' ? `Лучшие места категории «${name}» в Мармарисе — с фильтрами по районам и ценам, проверено местными.` : `Marmaris'teki en iyi ${name.toLowerCase()} listesi — mahalle ve fiyata göre filtrele, yerel onaylılardan seç.` return basicMetadata(title, description, locale, `/${categorySlug}`) } export default async function DynamicCategoryPage({ params, searchParams }: PageProps) { const { locale, category: categorySlug } = await params setRequestLocale(locale) const { search, neighborhood, price, approved } = await searchParams const t = await getTranslations('categories') const navT = await getTranslations('nav') const heroT = await getTranslations('hero') // Find Category Restoran const categories = await mockDb.getCategories() const currentCategory = categories.find(c => c.slug === categorySlug) if (!currentCategory) notFound() const categoryId = currentCategory?.id // Get active neighborhoods for filter const neighborhoods = await mockDb.getNeighborhoods() // Selected filters const selectedNeighborhoodId = neighborhood || undefined const selectedPriceRange = price ? parseInt(price) : undefined const isApprovedOnly = approved === 'true' const listings = await mockDb.getListings({ categoryId, neighborhoodId: selectedNeighborhoodId, priceRange: selectedPriceRange, isLocalApproved: isApprovedOnly ? true : undefined, search: search }) const getLocalizedName = (obj: any) => { if (!obj) return '' return locale === 'ru' ? obj.nameRu : locale === 'en' ? obj.nameEn : obj.nameTr } const homeLabel = locale === 'en' ? 'Home' : locale === 'ru' ? 'Главная' : 'Ana Sayfa' const breadcrumbLd = { '@context': 'https://schema.org', '@type': 'BreadcrumbList', itemListElement: [ { '@type': 'ListItem', position: 1, name: homeLabel, item: `https://marmarislocal.com/${locale}` }, { '@type': 'ListItem', position: 2, name: getLocalizedName(currentCategory), item: `https://marmarislocal.com/${locale}/${categorySlug}` }, ], } const itemListLd = { '@context': 'https://schema.org', '@type': 'ItemList', name: getLocalizedName(currentCategory), numberOfItems: listings.length, itemListElement: listings.map((item, index) => ({ '@type': 'ListItem', position: index + 1, url: `https://marmarislocal.com/${locale}/${categorySlug}/${item.slug}`, name: locale === 'ru' ? item.nameRu : locale === 'en' ? item.nameEn : item.nameTr, })), } return (