<?php
header('Content-Type: application/xml; charset=utf-8');
require_once 'config.php';

echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <url>
        <loc><?php echo SITE_URL; ?>/</loc>
        <priority>1.0</priority>
    </url>
    <url>
        <loc><?php echo SITE_URL; ?>/aide-renovation-2024</loc>
        <priority>0.9</priority>
    </url>
    <?php
    $regions = get_data('regions');
    foreach ($regions as $r) {
        echo '<url><loc>' . SITE_URL . '/region/' . $r['slug'] . '</loc><priority>0.8</priority></url>';
    }
    $deps = get_data('departements');
    foreach ($deps as $d) {
        echo '<url><loc>' . SITE_URL . '/departement/' . $d['slug'] . '</loc><priority>0.7</priority></url>';
    }
    // Pour les villes, idéalement on ferait un sitemap index, mais ici on en met un échantillon ou les principales
    $villes = get_data('villes');
    foreach (array_slice($villes, 0, 500) as $v) {
        echo '<url><loc>' . SITE_URL . '/ville/' . $v['slug'] . '</loc><priority>0.6</priority></url>';
    }
    ?>
</urlset>