<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">

    <!-- 首页 -->
    <url>
        <loc>https://www.dehua-ceramic.net/</loc>
        <lastmod><?php echo date('Y-m-d'); ?></lastmod>
        <changefreq>daily</changefreq>
        <priority>1.0</priority>
    </url>

    <!-- 文章页面 -->
    <?php
    require_once 'config.php';
    $pdo = getDB();
    $articles = $pdo->query("SELECT id, title, created_at, updated_at FROM articles WHERE is_published=1 ORDER BY created_at DESC")->fetchAll();
    foreach($articles as $article):
    ?>
    <url>
        <loc>https://www.dehua-ceramic.net/article.php?id=<?php echo $article['id']; ?></loc>
        <lastmod><?php echo date('Y-m-d', strtotime($article['updated_at'] ?? $article['created_at'])); ?></lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.8</priority>
    </url>
    <?php endforeach; ?>

    <!-- 作品页面 -->
    <?php
    $works = $pdo->query("SELECT id, title, created_at FROM works ORDER BY created_at DESC")->fetchAll();
    foreach($works as $work):
    ?>
    <url>
        <loc>https://www.dehua-ceramic.net/work.php?id=<?php echo $work['id']; ?></loc>
        <lastmod><?php echo date('Y-m-d', strtotime($work['created_at'])); ?></lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.7</priority>
    </url>
    <?php endforeach; ?>

</urlset>