Add basic sitemap

master
Markus Koch 2018-07-25 22:55:30 +02:00
parent 61131488c9
commit 4759b1577e
2 changed files with 33 additions and 0 deletions

View File

@ -219,6 +219,15 @@
apcu_store('posts', $posts, CACHE_POSTS_TTL); apcu_store('posts', $posts, CACHE_POSTS_TTL);
$CMS_INDEXING = false; $CMS_INDEXING = false;
} }
if (isset($CMS_SITEMAP)) {
foreach($posts as $k=>$v) {
if ($v->isPublic) {
echo "<url>\n\t<loc>" . htmlspecialchars($v->permalink) . "</loc>\n</url>\n";
}
}
return;
}
if (!isset($CMS_RSS)) if (!isset($CMS_RSS))

24
sitemap.php 100644
View File

@ -0,0 +1,24 @@
<?php
$CMS_ACTIVE = true;
$CMS_SITEMAP = true;
require_once "shared.php";
if (true) {
header('Content-type: application/xml');
?>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php
foreach ($menuItems as $item) {
$url = $item['link'];
if ($url[0] == "/")
$url = getServerUrl() . $url;
echo "<url>\n\t<loc>" . htmlspecialchars($url) . "</loc>\n</url>\n";
}
require "blog.php";
?>
</urlset>
<?php
}
?>