<?php
// sitemap.php (você pode salvar como sitemap.xml se preferir servir estático)
include 'includes/conexao.php';

header("Content-Type: application/xml; charset=utf-8");

echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">
<?php
$query = $conn->query("SELECT id, nome, caminho_imagem FROM artes ORDER BY id DESC");
while ($row = $query->fetch_assoc()):
    $id = $row['id'];
    $nome = htmlspecialchars($row['nome']);
    $img = 'https://corelize.com/' . $row['caminho_imagem'];
    $link = 'https://corelize.com/arte.php?id=' . $id;
?>
  <url>
    <loc><?= $link ?></loc>
    <image:image>
      <image:loc><?= $img ?></image:loc>
      <image:title><?= $nome ?></image:title>
    </image:image>
  </url>
<?php endwhile; ?>
</urlset>
