import { MetadataRoute } from 'next';
import { blogPostList } from '../lib/blog-data';

export default function sitemap(): MetadataRoute.Sitemap {
  const baseUrl = 'https://www.qrmaster.net';

  // All free tool slugs
  const freeTools = [
    'url-qr-code',
    'vcard-qr-code',
    'text-qr-code',
    'email-qr-code',
    'sms-qr-code',
    'wifi-qr-code',
    'crypto-qr-code',
    'event-qr-code',
    'facebook-qr-code',
    'instagram-qr-code',
    'twitter-qr-code',
    'youtube-qr-code',
    'whatsapp-qr-code',
    'tiktok-qr-code',
    'geolocation-qr-code',
    'phone-qr-code',
    'paypal-qr-code',
    'zoom-qr-code',
    'teams-qr-code',
  ];

  // All blog posts
  const blogPages = blogPostList.map((post) => ({
    url: `${baseUrl}/blog/${post.slug}`,
    lastModified: post.dateModified ? new Date(post.dateModified) : new Date(),
    changeFrequency: 'monthly' as const,
    priority: 0.8,
  }));

  const toolPages = freeTools.map((slug) => ({
    url: `${baseUrl}/tools/${slug}`,
    lastModified: new Date(),
    changeFrequency: 'monthly' as const,
    priority: 0.8,
  }));

  return [
    {
      url: baseUrl,
      lastModified: new Date(),
      changeFrequency: 'weekly',
      priority: 1.0,
    },
    {
      url: `${baseUrl}/qr-code-erstellen`,
      lastModified: new Date(),
      changeFrequency: 'weekly',
      priority: 1.0,
    },
    {
      url: `${baseUrl}/qr-code-tracking`,
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.9,
    },
    {
      url: `${baseUrl}/reprint-calculator`,
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.9,
    },
    {
      url: `${baseUrl}/dynamic-qr-code-generator`,
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.9,
    },
    {
      url: `${baseUrl}/bulk-qr-code-generator`,
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.9,
    },
    {
      url: `${baseUrl}/pricing`,
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.8,
    },
    {
      url: `${baseUrl}/faq`,
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.7,
    },
    {
      url: `${baseUrl}/blog`,
      lastModified: new Date(),
      changeFrequency: 'weekly',
      priority: 0.8,
    },
    {
      url: `${baseUrl}/signup`,
      lastModified: new Date(),
      changeFrequency: 'monthly',
      priority: 0.8,
    },
    {
      url: `${baseUrl}/login`,
      lastModified: new Date(),
      changeFrequency: 'yearly',
      priority: 0.5,
    },
    {
      url: `${baseUrl}/privacy`,
      lastModified: new Date(),
      changeFrequency: 'yearly',
      priority: 0.4,
    },

    ...toolPages,
    ...blogPages,
  ];
}

