Files
squi.bid/misc/tools.php
Squibid 1bc1454b93 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
2023-10-30 12:47:55 -04:00

28 lines
788 B
PHP

<?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 : "¯\_(ツ)_/¯");
}
}
?>