<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
    <?php
    require_once 'admin/config/database.php';
    
    // Articles
    $stmt = $pdo->query("SELECT slug, updated_at FROM articles WHERE status = 'published'");
    while ($article = $stmt->fetch()) {
        echo "<url>\n";
        echo "  <loc>https://top-ou-flop.com/" . htmlspecialchars($article['slug']) . "</loc>\n";
        echo "  <lastmod>" . date('Y-m-d', strtotime($article['updated_at'])) . "</lastmod>\n";
        echo "  <changefreq>weekly</changefreq>\n";
        echo "  <priority>0.8</priority>\n";
        echo "</url>\n";
    }
    
    // Catégories
    $stmt = $pdo->query("SELECT slug FROM categories");
    while ($category = $stmt->fetch()) {
        echo "<url>\n";
        echo "  <loc>https://top-ou-flop.com/categorie/" . htmlspecialchars($category['slug']) . "</loc>\n";
        echo "  <changefreq>weekly</changefreq>\n";
        echo "  <priority>0.6</priority>\n";
        echo "</url>\n";
    }
    ?>
</urlset> 