Add automatically-updating-pureblog-sitemap.php
This commit is contained in:
parent
bc60bf43ab
commit
429693eea5
1 changed files with 42 additions and 0 deletions
42
automatically-updating-pureblog-sitemap.php
Normal file
42
automatically-updating-pureblog-sitemap.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php 4.1s
|
||||
|
||||
require PUREBLOG_BASE_PATH . '/includes/header.php';
|
||||
render_masthead_layout($config, ['page' => null]);
|
||||
|
||||
?>
|
||||
|
||||
<main>
|
||||
<h1> Sitemap</h1>
|
||||
|
||||
<?php
|
||||
|
||||
$directory = '/var/www/html/content/pages/';
|
||||
|
||||
$files = scandir($directory);
|
||||
|
||||
echo "<ul>";
|
||||
|
||||
foreach ($files as $file) {
|
||||
if ($file !== "." && $file !== "..") {
|
||||
$name = pathinfo($file, PATHINFO_FILENAME);
|
||||
$path = $directory . '/' . $file;
|
||||
$contents = file_get_contents($path);
|
||||
|
||||
preg_match('/^title:\s*(.+)$/m', $contents, $matches);
|
||||
|
||||
$title = $matches[1] ?? pathinfo($file, PATHINFO_FILENAME);
|
||||
|
||||
$url = '/' . pathinfo($file, PATHINFO_FILENAME);
|
||||
|
||||
echo '<li>🛸 <a href="' . htmlspecialchars($url) . '">'
|
||||
. htmlspecialchars(trim($title))
|
||||
. '</a></li>';
|
||||
}
|
||||
}
|
||||
echo "</ul>";
|
||||
?>
|
||||
|
||||
</main>
|
||||
<?php render_footer_layout($config, ['page' => null]); ?>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Reference in a new issue