diff --git a/app/[locale]/[category]/[slug]/page.tsx b/app/[locale]/[category]/[slug]/page.tsx index 8f1f006..6ed46df 100644 --- a/app/[locale]/[category]/[slug]/page.tsx +++ b/app/[locale]/[category]/[slug]/page.tsx @@ -7,6 +7,8 @@ import { Link } from '@/i18n/routing' import { Phone, Globe, MapPin, Clock, Star, MessageSquare, Share2 } from 'lucide-react' import SaveButton from './SaveButton' import DetailTracker from './DetailTracker' +import type { Metadata } from 'next' +import { SITE_URL } from '@/lib/seo' interface DetailPageProps { params: Promise<{ locale: string; category: string; slug: string }> @@ -14,14 +16,32 @@ interface DetailPageProps { export const dynamic = 'force-dynamic' -export async function generateMetadata({ params }: DetailPageProps) { - const { slug } = await params +export async function generateMetadata({ params }: DetailPageProps): Promise { + const { locale, slug } = await params const listing = await mockDb.getListingBySlug(slug) if (!listing) return {} + const name = locale === 'ru' ? listing.nameRu : locale === 'en' ? listing.nameEn : listing.nameTr + const description = locale === 'ru' ? listing.descriptionRu : locale === 'en' ? listing.descriptionEn : listing.descriptionTr + const title = `${name} — Marmaris Local` + const image = listing.images?.[0]?.url + return { - title: `${listing.nameTr} — Marmaris Local`, - description: listing.descriptionTr + title, + description, + openGraph: { + title, + description, + url: `${SITE_URL}/${locale}/${listing.category?.slug || 'isletme'}/${listing.slug}`, + siteName: 'Marmaris Local', + type: 'website', + ...(image ? { images: [{ url: image }] } : {}), + }, + twitter: { + card: 'summary_large_image', + title, + description, + }, } } @@ -86,8 +106,43 @@ export default async function ListingDetailPage({ params }: DetailPageProps) { return `https://wa.me/?text=${text}` } + // schema.org LocalBusiness structured data + const schemaTypeByCategory: Record = { + restoran: 'Restaurant', + apart: 'LodgingBusiness', + isletme: 'LocalBusiness', + } + + const jsonLd = { + '@context': 'https://schema.org', + '@type': schemaTypeByCategory[categorySlug] || 'LocalBusiness', + name, + description, + image: listing.images?.map(img => img.url) || undefined, + url: `https://marmarislocal.com/${locale}/${categorySlug}/${listing.slug}`, + address: { + '@type': 'PostalAddress', + streetAddress: listing.address, + addressLocality: 'Marmaris', + addressCountry: 'TR', + }, + ...(listing.latitude && listing.longitude + ? { geo: { '@type': 'GeoCoordinates', latitude: listing.latitude, longitude: listing.longitude } } + : {}), + ...(listing.phone ? { telephone: listing.phone } : {}), + ...(listing.website ? { sameAs: [listing.website] } : {}), + priceRange: priceSymbols || undefined, + ...(listing.openingHours && (listing.openingHours as any).all + ? { openingHours: (listing.openingHours as any).all } + : {}), + } + return (
+