Generate sitemap dynamically

dev
gravel 7 months ago
parent 984c862722
commit fc14e4586a
Signed by: gravel
GPG Key ID: C0538F3C906B308F

3
.gitignore vendored

@ -1,9 +1,10 @@
# Fetched room info
output/servers.json
# Generated HTML
# Generated files
output/*.html
output/**/*.html
output/sitemap.xml
# Downloaded QR codes
output/qr-codes

@ -1,27 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<?php
require_once '+getenv.php';
function loc_lastmod(string $rel_loc, ?string $changes_under_root = null) {
global $SITE_CANONICAL_URL, $DOCUMENT_ROOT, $TEMPLATES_ROOT;
$root = $changes_under_root ?? $TEMPLATES_ROOT;
$ext = ($root == $TEMPLATES_ROOT) ? "php" : "html";
?>
<loc><?=$SITE_CANONICAL_URL . $rel_loc?></loc>
<lastmod><?=date('c', filemtime("$root$rel_loc/index.$ext"))?></lastmod>
<?php
}
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://sessioncommunities.online/</loc>
<?=loc_lastmod("", changes_under_root: $DOCUMENT_ROOT)?>
<changefreq>hourly</changefreq>
<priority>1.0</priority>
</url>
<url>
<loc>https://sessioncommunities.online/about</loc>
<?=loc_lastmod("/about")?>
<changefreq>monthly</changefreq>
<priority>0.7</priority>
</url>
<url>
<loc>https://sessioncommunities.online/privacy</loc>
<?=loc_lastmod("/privacy")?>
<changefreq>monthly</changefreq>
<priority>0.0</priority>
</url>
<url>
<loc>https://sessioncommunities.online/donate</loc>
<?=loc_lastmod("/donate")?>
<changefreq>monthly</changefreq>
<priority>0.0</priority>
</url>
<url>
<loc>https://sessioncommunities.online/instructions</loc>
<?=loc_lastmod("/instructions")?>
<changefreq>monthly</changefreq>
<priority>0.0</priority>
</url>
Loading…
Cancel
Save