Add basic sitemap

This commit is contained in:
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

@ -220,6 +220,15 @@
$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))
echo "<blog>";

24
sitemap.php Normal file
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
}
?>