Merge pull request #12 from audiodude/wiki-sort-articles

Sort wiki articles by actual title instead of filename
This commit is contained in:
deepend-tildeclub 2020-04-12 08:36:32 -06:00 committed by GitHub
commit bddf5ef406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 6 deletions

View File

@ -7,14 +7,18 @@ include __DIR__."/../header.php";
<p>here's the articles on our wiki:</p>
<ul>
<?php foreach (glob("source/*.md") as $file) {
$article = basename($file, ".md");
$title = preg_match("/title: (.*)/i", file_get_contents($file), $matches)
? $matches[1] : $article;
?>
<?php
$article_to_title = [];
foreach (glob("source/*.md") as $file) {
$article = basename($file, ".md");
$title = preg_match("/title: (.*)/i", file_get_contents($file), $matches) ? $matches[1] : $article;
$article_to_title[$article] = $title;
}
asort($article_to_title);
?>
<?php foreach ($article_to_title as $article => $title) { ?>
<li><a href="/wiki/<?=$article?>.html"><?=$title?></a></li>
<?php } ?>
</ul>
<?php include __DIR__."/../footer.php";