/** @type {import('next-sitemap').IConfig} */
module.exports = {
  siteUrl: process.env.NEXT_PUBLIC_SITE_URL || "https://biztaghavi.com",
  generateRobotsTxt: true,
  generateIndexSitemap: false,
  changefreq: "weekly",
  priority: 0.7,
  exclude: ["/studio/*", "/api/*", "/en/studio/*"],
  alternateRefs: [
    { href: "https://biztaghavi.com", hreflang: "fa" },
    { href: "https://biztaghavi.com/en", hreflang: "en" },
    { href: "https://biztaghavi.com", hreflang: "x-default" },
  ],
  robotsTxtOptions: {
    policies: [
      { userAgent: "*", allow: "/" },
      { userAgent: "*", disallow: ["/studio", "/api"] },
    ],
    additionalSitemaps: [],
  },
  transform: async (config, path) => {
    // Boost priority for key pages
    const highPriority = ["/", "/en", "/about", "/en/about", "/writing", "/en/writing"];
    const priority = highPriority.includes(path) ? 1.0 : config.priority;
    return {
      loc: path,
      changefreq: config.changefreq,
      priority,
      lastmod: config.autoLastmod ? new Date().toISOString() : undefined,
      alternateRefs: config.alternateRefs ?? [],
    };
  },
};
