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

echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

// Homepage
echo "<url><loc>https://logede.biz.id/</loc><priority>1.0</priority></url>";

// Kategori
$kategori = $conn->query("SELECT slug FROM kategori");
while ($k = $kategori->fetch_assoc()) {
  echo "<url><loc>https://logede.biz.id/kategori/{$k['slug']}</loc><priority>0.7</priority></url>";
}

// Produk
$produk = $conn->query("SELECT slug FROM produk WHERE status = 'aktif'");
while ($p = $produk->fetch_assoc()) {
  echo "<url><loc>https://logede.biz.id/produk/{$p['slug']}</loc><priority>0.8</priority></url>";
}

echo '</urlset>';
?>
