import { MetadataRoute } from 'next';
import { prisma } from '@/lib/db';

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
  const settings = await prisma.siteSettings.findFirst();
  const siteUrl = settings?.siteUrl || 'https://moybeach.com';
  const now = new Date();

  return [
    {
      url: `${siteUrl}/tr`,
      lastModified: now,
      changeFrequency: 'weekly',
      priority: 1,
      alternates: {
        languages: {
          tr: `${siteUrl}/tr`,
          en: `${siteUrl}/en`,
        },
      },
    },
    {
      url: `${siteUrl}/en`,
      lastModified: now,
      changeFrequency: 'weekly',
      priority: 1,
      alternates: {
        languages: {
          tr: `${siteUrl}/tr`,
          en: `${siteUrl}/en`,
        },
      },
    },
  ];
}
