-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitemap.php
More file actions
48 lines (39 loc) · 1.42 KB
/
sitemap.php
File metadata and controls
48 lines (39 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
require __DIR__ . '/src/Config.php';
require __DIR__ . '/src/Constants.php';
require __DIR__ . '/src/Utils.php';
require __DIR__ . '/src/RenderMarkdown.php';
require __DIR__ . '/src/MarkdownProcessor.php';
require __DIR__ . '/src/IndexManager.php';
require __DIR__ . '/src/PageGenerator.php';
require __DIR__ . '/src/Content.php';
require __DIR__ . '/src/Sitemap.php';
require __DIR__ . '/src/Language.php';
use BitBlog\Config;
use BitBlog\Constants;
use BitBlog\Content;
use BitBlog\Language;
use BitBlog\Sitemap;
date_default_timezone_set(Config::TIMEZONE);
// Ensure consistent locale for IntlDateFormatter (independent of server defaults)
\Locale::setDefault(Language::getLocale());
// Set XML headers
header('Content-Type: application/xml; charset=UTF-8');
header('Cache-Control: public, max-age=86400'); // 24 hour cache for sitemap
$content = new Content(
Config::CONTENT_DIR,
Config::CACHE_DIR,
Config::BASE_URL()
);
// Gather comprehensive sitemap data
$posts = array_filter($content->getIndex(), fn($p) => $p['status'] === Constants::POST_STATUS_PUBLISHED);
$categories = $content->getTagCloud();
$staticPages = ['about']; // Add your static pages here
$additionalData = [
'posts' => $posts,
'categories' => $categories,
'pages' => $staticPages
];
echo Sitemap::build($content->getAllPostUrls(), Config::BASE_URL(), $additionalData);
?>