<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
        http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

    <!-- ===== ГЛАВНАЯ СТРАНИЦА ===== -->
    <url>
        <loc>https://shushpc.ru/</loc>
        <lastmod>2026-07-09</lastmod>
        <changefreq>weekly</changefreq>
        <priority>1.0</priority>
    </url>

    <!-- ===== ЯКОРЯ НА ГЛАВНОЙ ===== -->
    <url>
        <loc>https://shushpc.ru/#expertise</loc>
        <lastmod>2026-07-09</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://shushpc.ru/#work</loc>
        <lastmod>2026-07-09</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>https://shushpc.ru/#contact</loc>
        <lastmod>2026-07-09</lastmod>
        <changefreq>monthly</changefreq>
        <priority>0.8</priority>
    </url>

    <!-- ===== СТРАНИЦЫ ===== -->
    <url>
        <loc>https://shushpc.ru/privacy</loc>
        <lastmod>2026-07-09</lastmod>
        <changefreq>yearly</changefreq>
        <priority>0.3</priority>
    </url>
    <url>
        <loc>https://shushpc.ru/404</loc>
        <lastmod>2026-07-09</lastmod>
        <changefreq>yearly</changefreq>
        <priority>0.3</priority>
    </url>

    <!-- ===== БЛОГ ===== -->
    <url>
        <loc>https://shushpc.ru/blog/</loc>
        <lastmod>2026-07-09</lastmod>
        <changefreq>weekly</changefreq>
        <priority>0.9</priority>
    </url>

    <!-- СТАТЬИ БЛОГА (динамически) -->
    <?php
    $postsFile = __DIR__ . '/admin/data/blog_posts.json';
    if (file_exists($postsFile)) {
        $posts = json_decode(file_get_contents($postsFile), true);
        if (is_array($posts)) {
            // Только опубликованные
            $posts = array_filter($posts, fn($p) => isset($p['active']) && $p['active'] === true);
            // Сортируем по дате (новые сверху)
            usort($posts, function($a, $b) {
                return strtotime($b['date'] ?? 0) - strtotime($a['date'] ?? 0);
            });
            foreach ($posts as $p) {
                $slug = $p['slug'] ?? '';
                if (empty($slug)) continue;
                $date = date('Y-m-d', strtotime($p['date'] ?? 'now'));
                ?>
                <url>
                    <loc>https://shushpc.ru/blog/<?= htmlspecialchars($slug) ?></loc>
                    <lastmod><?= $date ?></lastmod>
                    <changefreq>monthly</changefreq>
                    <priority>0.7</priority>
                </url>
                <?php
            }
        }
    }
    ?>

</urlset>