export default {
  async fetch(request) {
    const url = new URL(request.url);
    if (url.pathname !== "/sitemap.xml") return fetch(request);

    const body = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url><loc>https://cryptoplater.com/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>weekly</changefreq><priority>0.8</priority></url>
  <url><loc>https://cryptoplater.com/exchanges/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>weekly</changefreq><priority>0.6</priority></url>
  <url><loc>https://cryptoplater.com/cryptocurrencies/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>weekly</changefreq><priority>0.6</priority></url>
  <url><loc>https://cryptoplater.com/wallets/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>weekly</changefreq><priority>0.6</priority></url>
  <url><loc>https://cryptoplater.com/cards/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>weekly</changefreq><priority>0.6</priority></url>
  <url><loc>https://cryptoplater.com/deals/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>weekly</changefreq><priority>0.6</priority></url>
  <url><loc>https://cryptoplater.com/about/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>weekly</changefreq><priority>0.6</priority></url>
  <url><loc>https://cryptoplater.com/privacy-policy/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>yearly</changefreq><priority>0.4</priority></url>
  <url><loc>https://cryptoplater.com/terms-of-use/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>yearly</changefreq><priority>0.4</priority></url>
  <url><loc>https://cryptoplater.com/advertiser-disclosure/</loc><lastmod>${new Date().toISOString().slice(0,10)}</lastmod><changefreq>yearly</changefreq><priority>0.4</priority></url>
</urlset>`;
    return new Response(body, {
      headers: {
        "content-type": "application/xml; charset=utf-8",
        "cache-control": "public, max-age=3600"
      }
    });
  }
}
