import { SITE_URL } from '@/lib/seo';
import type { MetadataRoute } from 'next';

type Entry = {
  path: string;
  priority: number;
  changeFrequency: MetadataRoute.Sitemap[number]['changeFrequency'];
};

const ROUTES: Entry[] = [
  { path: '/', priority: 1.0, changeFrequency: 'weekly' },
  { path: '/pricing', priority: 0.9, changeFrequency: 'weekly' },
  { path: '/templates', priority: 0.9, changeFrequency: 'daily' },
  { path: '/docs', priority: 0.8, changeFrequency: 'weekly' },
  { path: '/docs/concepts', priority: 0.7, changeFrequency: 'monthly' },
  { path: '/docs/oauth', priority: 0.7, changeFrequency: 'monthly' },
  { path: '/docs/authoring', priority: 0.7, changeFrequency: 'monthly' },
  { path: '/docs/api-reference', priority: 0.7, changeFrequency: 'monthly' },
  { path: '/docs/self-hosting', priority: 0.7, changeFrequency: 'monthly' },
  { path: '/docs/faq', priority: 0.6, changeFrequency: 'monthly' },
  { path: '/changelog', priority: 0.6, changeFrequency: 'weekly' },
  { path: '/security', priority: 0.5, changeFrequency: 'monthly' },
  { path: '/status', priority: 0.4, changeFrequency: 'weekly' },
  { path: '/privacy', priority: 0.3, changeFrequency: 'yearly' },
  { path: '/terms', priority: 0.3, changeFrequency: 'yearly' },
];

export default function sitemap(): MetadataRoute.Sitemap {
  const now = new Date();
  return ROUTES.map((r) => ({
    url: `${SITE_URL}${r.path}`,
    lastModified: now,
    changeFrequency: r.changeFrequency,
    priority: r.priority,
  }));
}
