fix sitemap

This commit is contained in:
ghost 2023-08-30 19:12:12 +03:00
parent cbdff05c2a
commit d9df3578d9
2 changed files with 1 additions and 1 deletions

3
src/public/robots.txt Normal file
View file

@ -0,0 +1,3 @@
User-agent: *
Sitemap: /sitemap.php

25
src/public/sitemap.php Normal file
View file

@ -0,0 +1,25 @@
<?php
header('Content-type: application/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset>';
if ($signals = file_get_contents(__DIR__ . '/../../SIGNALS/YGGDRASIL.md')) {
foreach (explode(PHP_EOL, $signals) as $signal) {
if (preg_match('/\[(.*?)\]\((.*?)\)/ui', $signal, $data)) {
if (!empty($data[1]) && !empty($data[2])) {
if ($host = parse_url($data[2], PHP_URL_HOST)) {
echo sprintf('<url><loc>%s</loc></url>', htmlentities($data[2]));
}
}
}
}
}
echo '</urlset>';