<?php
declare(strict_types=1);

require_once __DIR__ . '/includes/I18n.php';

header('Content-Type: application/xml; charset=utf-8');
header('X-Robots-Tag: noindex');

$baseUrl = 'https://chat.3w3.org';
$now = date('Y-m-d');

$staticPages = [
    ['loc' => '/about',   'changefreq' => 'monthly', 'priority' => '0.7'],
    ['loc' => '/contact', 'changefreq' => 'monthly', 'priority' => '0.6'],
    ['loc' => '/support', 'changefreq' => 'monthly', 'priority' => '0.6'],
    ['loc' => '/privacy', 'changefreq' => 'yearly',  'priority' => '0.4'],
    ['loc' => '/terms',   'changefreq' => 'yearly',  'priority' => '0.4'],
];

echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach (I18n::SUPPORTED as $lang): ?>
    <url>
        <loc><?= htmlspecialchars($baseUrl . I18n::pathForLang($lang, '/')) ?></loc>
        <lastmod><?= $now ?></lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>
<?php endforeach; ?>

<?php foreach ($staticPages as $page): ?>
    <url>
        <loc><?= htmlspecialchars($baseUrl . $page['loc']) ?></loc>
        <lastmod><?= $now ?></lastmod>
        <changefreq><?= $page['changefreq'] ?></changefreq>
        <priority><?= $page['priority'] ?></priority>
    </url>
<?php endforeach; ?>
</urlset>
