import { MetadataRoute } from 'next'; import sql from '@/lib/db'; export default async function sitemap(): Promise { const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || "https://mugladijitalmedya.com"; // Static pages const staticPages = [ '', '/about', '/services', '/works', '/contact', ].map((route) => ({ url: `${baseUrl}${route}`, lastModified: new Date(), changeFrequency: 'weekly' as const, priority: route === '' ? 1 : 0.8, })); // Dynamic projects const projects = await sql`SELECT slug, updated_at FROM projects`; const projectPages = (projects || []).map((project) => ({ url: `${baseUrl}/works/${project.slug}`, lastModified: new Date(project.updated_at || new Date()), changeFrequency: 'monthly' as const, priority: 0.6, })); // Programmatic SEO pages (Services + Locations) const [services, locations] = await Promise.all([ sql`SELECT slug FROM services`, sql`SELECT slug FROM locations` ]); const pSeoPages = []; for (const service of services) { for (const location of locations) { pSeoPages.push({ url: `${baseUrl}/services/${service.slug}/${location.slug}`, lastModified: new Date(), changeFrequency: 'weekly' as const, priority: 0.7, }); } } return [...staticPages, ...projectPages, ...pSeoPages]; }