New blog entry and changes to how blogs are displayed

- blogs are now in subdirs
 - blog list is generated through helper function
 - full blog list is in blog subdir
This commit is contained in:
2023-10-30 12:47:55 -04:00
parent 2d90cc6151
commit 1bc1454b93
9 changed files with 100 additions and 45 deletions

27
misc/tools.php Normal file
View File

@ -0,0 +1,27 @@
<?php
function entries($path = "blog", $limit = false) {
$files = scandir($path."/");
$entries = [];
$i = 0;
foreach ($files as $file) {
if (is_dir($path.'/'.$file) && $file[0] != ".") {
$tags = get_meta_tags($path.'/'.$file.'/index.html');
$entries[$i][0] = preg_replace("/\//", "", $tags["date"]);
$entries[$i][1] = $file;
$entries[$i][2] = $tags["date"];
$i++;
}
}
rsort($entries);
for ($i = 0; $i < count($entries); $i++) {
if ($limit && $i > $limit - 1)
break;
$file = $entries[$i][1];
$age = $entries[$i][2];
printf('<a href=/%s/%s>%s</a><span>%s</span><br>',
$path, $file, str_replace("-", " ", $file),
$age ? $age : "¯\_(ツ)_/¯");
}
}
?>