import { mockDb } from '@/lib/mockDb' export async function GET() { const baseUrl = 'https://marmarislocal.com' // Fetch data const posts = await mockDb.getBlogPosts(true) const listings = await mockDb.getListings({ isLocalApproved: true }) // Construct XML let xml = ` Marmaris Local ${baseUrl} Marmaris'in yerel rehberi, gurme mekanları ve gezilecek gizli yerleri. tr ${new Date().toUTCString()} ` // Add blog posts for (const post of posts.slice(0, 10)) { const pubDate = post.publishedAt ? new Date(post.publishedAt).toUTCString() : new Date(post.createdAt).toUTCString() xml += ` <![CDATA[${post.titleTr}]]> ${baseUrl}/tr/blog/${post.slug} ${baseUrl}/tr/blog/${post.slug} ${pubDate} ` } // Add newly added approved listings for (const listing of listings.slice(0, 10)) { const pubDate = new Date(listing.createdAt).toUTCString() const catSlug = listing.category?.slug || 'businesses' xml += ` <![CDATA[Yeni Onaylandı: ${listing.nameTr} (${listing.neighborhood?.nameTr})]]> ${baseUrl}/tr/${catSlug}/${listing.slug} ${baseUrl}/tr/${catSlug}/${listing.slug} ${pubDate} ` } xml += ` ` return new Response(xml, { headers: { 'Content-Type': 'application/xml; charset=utf-8', 'Cache-Control': 'public, s-maxage=86400, stale-while-revalidate=43200' } }) }