38 lines
1 KiB
PHP
38 lines
1 KiB
PHP
<?php
|
|
// modified from https://codeberg.org/fsfans-cn/www/src/branch/new/template/dirlisting.php
|
|
$child_pages = [];
|
|
|
|
foreach (get_page_list("page") as $path) {
|
|
$child_page = get_page($path);
|
|
if (
|
|
(isset($child_page["unlisted"]) && $child_page["unlisted"])
|
|
|| $page["path"] == $path
|
|
) continue;
|
|
$href = "/" . substr_replace($child_page["path"], "html", -2);
|
|
if ($pos = strrpos($href, "/index.html")) {
|
|
$href = substr($href, 0, $pos + 1);
|
|
}
|
|
$date = 0;
|
|
if (!empty($child_page["date"]))
|
|
$date = date_create($child_page["date"]);
|
|
else
|
|
$date = filemtime("src/" . $child_page["path"]);
|
|
array_push($child_pages, [
|
|
"title" => $child_page["title"],
|
|
"date" => $date,
|
|
"href" => $href
|
|
]);
|
|
}
|
|
|
|
array_multisort(
|
|
array_column($child_pages, "date"), SORT_DESC,
|
|
$child_pages
|
|
);
|
|
?>
|
|
<?php echo $page["content"] ?>
|
|
<ul class="pages-index">
|
|
<?php
|
|
foreach ($child_pages as $page)
|
|
echo "<li><span>", date("Y-m-d", $page["date"]), "</span> | <a href=\"", $page["href"], "\">", $page["title"], "</a></li>\n";
|
|
?>
|
|
</ul>
|