<?php
declare(strict_types=1);
$config = require __DIR__ . '/app/config.php';
header('Content-Type: application/xml; charset=utf-8');
$base = rtrim($config['site_url'], '/');
$today = date('Y-m-d');

// Define pages with priorities and change frequencies
$pages = [
  ['url' => '/', 'priority' => '1.0', 'changefreq' => 'weekly'],
  ['url' => '/services/', 'priority' => '0.9', 'changefreq' => 'monthly'],
  ['url' => '/services/diesel-repair/', 'priority' => '0.9', 'changefreq' => 'monthly'],
  ['url' => '/services/auto-body/', 'priority' => '0.9', 'changefreq' => 'monthly'],
  ['url' => '/services/semi-truck/', 'priority' => '0.9', 'changefreq' => 'monthly'],
  ['url' => '/services/mobile-repair/', 'priority' => '0.9', 'changefreq' => 'monthly'],
  ['url' => '/towing-services/', 'priority' => '0.9', 'changefreq' => 'monthly'],
  ['url' => '/service-area/', 'priority' => '0.8', 'changefreq' => 'monthly'],
  ['url' => '/about/', 'priority' => '0.7', 'changefreq' => 'monthly'],
  ['url' => '/gallery/', 'priority' => '0.6', 'changefreq' => 'weekly'],
  ['url' => '/contact/', 'priority' => '0.7', 'changefreq' => 'monthly'],
  ['url' => '/privacy-policy/', 'priority' => '0.3', 'changefreq' => 'yearly'],
  ['url' => '/terms-and-conditions/', 'priority' => '0.3', 'changefreq' => 'yearly'],
  ['url' => '/accessibility/', 'priority' => '0.3', 'changefreq' => 'yearly'],
];

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
echo "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
foreach ($pages as $page) {
  echo "  <url>\n";
  echo "    <loc>" . htmlspecialchars($base . $page['url']) . "</loc>\n";
  echo "    <lastmod>" . $today . "</lastmod>\n";
  echo "    <changefreq>" . $page['changefreq'] . "</changefreq>\n";
  echo "    <priority>" . $page['priority'] . "</priority>\n";
  echo "  </url>\n";
}
echo "</urlset>";
