<?php
require_once 'config.php';

header('Content-Type: application/xml; charset=UTF-8');

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
  <url>
    <loc><?= SITE_URL ?>/</loc>
    <priority>1.0</priority>
    <changefreq>weekly</changefreq>
  </url>
  <url>
    <loc><?= SITE_URL ?>/about-us</loc>
    <priority>0.8</priority>
    <changefreq>monthly</changefreq>
  </url>
  <url>
    <loc><?= SITE_URL ?>/services</loc>
    <priority>0.9</priority>
    <changefreq>monthly</changefreq>
  </url>
  <url>
    <loc><?= SITE_URL ?>/contact</loc>
    <priority>0.7</priority>
    <changefreq>monthly</changefreq>
  </url>
  <url>
    <loc><?= SITE_URL ?>/alliances</loc>
    <priority>0.8</priority>
    <changefreq>monthly</changefreq>
  </url>
  <url>
    <loc><?= SITE_URL ?>/blog</loc>
    <priority>0.8</priority>
    <changefreq>weekly</changefreq>
  </url>
<?php
require_once __DIR__ . '/includes/blog.php';
foreach (blog_published_posts() as $post):
  if (empty($post['slug'])) continue;
?>
  <url>
    <loc><?= SITE_URL . blog_post_url($post) ?></loc>
    <lastmod><?= date('Y-m-d', strtotime($post['updated_at'] ?? $post['created_at'] ?? 'now')) ?></lastmod>
    <priority>0.6</priority>
    <changefreq>monthly</changefreq>
  </url>
<?php endforeach; ?>
</urlset>
