mirror of https://github.com/tildeclub/site.git
Sort wiki articles by actual title instead of filename
This commit is contained in:
parent
24b0fdd592
commit
ea181def2f
|
@ -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;
|
||||
}
|
||||
sort($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";
|
||||
|
||||
|
|
Loading…
Reference in New Issue