<?php
header("Content-Type: text/xml; charset=UTF-8");

// Koneksi ke database
require_once("koneksi.php"); 

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

// **1. Peta Situs untuk halaman landingpage**
$sql = "SELECT slug_url, updated_at FROM landingpage ORDER BY updated_at DESC";
$result = $conn->query($sql);

while ($row = $result->fetch_assoc()) {
    echo '<url>';
    echo '<loc>' . htmlspecialchars("https://portalumkm.com/" . $row['slug_url'] . '/') . '</loc>';

    echo '<lastmod>' . date('Y-m-d', strtotime($row['updated_at'])) . '</lastmod>';
    echo '<priority>1.0</priority>';
    echo '</url>';
}

echo '</urlset>';
$conn->close();
?>