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:
27
misc/tools.php
Normal file
27
misc/tools.php
Normal 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 : "¯\_(ツ)_/¯");
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user