import type { MetadataRoute } from "next";

import { marketingFeatures } from "@/lib/marketing/features";

function getSiteUrl() {
  return process.env.NEXT_PUBLIC_SITE_URL ?? "https://mein-kitaplaner.de";
}

export default function sitemap(): MetadataRoute.Sitemap {
  const siteUrl = getSiteUrl();
  const lastModified = new Date();

  return [
    {
      url: siteUrl,
      lastModified,
      changeFrequency: "weekly",
      priority: 1,
    },
    {
      url: `${siteUrl}/impressum`,
      lastModified,
      changeFrequency: "yearly",
      priority: 0.2,
    },
    {
      url: `${siteUrl}/datenschutz`,
      lastModified,
      changeFrequency: "yearly",
      priority: 0.2,
    },
    ...marketingFeatures.map((feature) => ({
      url: `${siteUrl}/features/${feature.slug}`,
      lastModified,
      changeFrequency: "monthly" as const,
      priority: 0.8,
    })),
  ];
}
