const { SitemapStream, streamToPromise } = require("sitemap");
const { Readable } = require("stream");

const routes = [
  "/",
  "/dashboard",
  "/pricing",
  "/docs",
  "/help", // Added help page
  "/guide",
  "/status",
  "/signup",
  "/login",
  "/forgot-password",
  "/features",
  "/profile",
  "/blog",
  // Add individual blog posts if you have them, e.g.:
  "/blog/maximizing-uptime-with-pulseguard",
  "/blog/understanding-server-forecasting",
  "/blog/securing-api-credentials",
  "/blog/ssl-monitoring-matters",
  "/blog/integrate-pulseguard-with-aws",
  "/blog/future-of-website-monitoring"
];

const sitemap = new SitemapStream({ hostname: "https://pulseguard.in" });

const stream = Readable.from(
  routes.map((route) => ({
    url: route,
    changefreq: route.startsWith("/blog") || route === "/help" ? "weekly" : "monthly",
    priority: route === "/" ? 1.0 : route.startsWith("/blog") || route === "/help" ? 0.9 : 0.8,
  }))
);
stream.pipe(sitemap).pipe(process.stdout);

streamToPromise(sitemap).then(() => {
  console.log("Sitemap generated");
});