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

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

  return {
    rules: [
      {
        userAgent: '*',
        allow: '/',
        disallow: ['/admin/', '/api/'],
      },
    ],
    sitemap: `${siteUrl}/sitemap.xml`,
    host: siteUrl,
  };
}
