forked from team/site
1
0
Fork 0

use title from md instead of filename for page title

This commit is contained in:
Ben Harris 2018-06-08 20:36:52 -04:00
parent e98e9b89c4
commit 31fd8a479b
2 changed files with 20 additions and 15 deletions

View File

@ -14,37 +14,42 @@ a.anchor {
} }
</style> </style>
'; ';
include __DIR__.'/../header.php';
$parser = new Mni\FrontYAML\Parser(); $parser = new Mni\FrontYAML\Parser();
if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) { if (!isset($_GET["page"]) || !file_exists("pages/{$_GET['page']}.md")) {
// render wiki index ?> $title = "tilde.team~wiki";
include __DIR__.'/../header.php';
// render wiki index ?>
<h1>tilde.team wiki</h1> <h1>tilde.team wiki</h1>
<p>welcome to the tilde.team wiki!</p> <p>welcome to the tilde.team wiki!</p>
<p>if you want to contribute, check out the <a href="https://git.tilde.team/meta/site/src/branch/master/wiki">source!</a></p> <p>if you want to contribute, check out the <a href="https://git.tilde.team/meta/site/src/branch/master/wiki">source!</a></p>
<hr> <hr>
<h3>pages:</h3> <h3>pages:</h3>
<?php <?php
foreach (glob("pages/*.md") as $page) { foreach (glob("pages/*.md") as $page) {
$yaml = $parser->parse(file_get_contents($page))->getYAML(); $yaml = $parser->parse(file_get_contents($page))->getYAML();
if (!$yaml["published"]) continue; ?> if (!$yaml["published"]) continue; ?>
<a href="/wiki/?page=<?=basename($page, ".md")?>"><?=$yaml["title"]?></a><br> <a href="/wiki/?page=<?=basename($page, ".md")?>"><?=$yaml["title"]?></a><br>
<?php } <?php }
} else { } else {
$pg = $parser->parse(file_get_contents("pages/{$_GET["page"]}.md"));
$title = $pg->getYAML()['title'] . " | tilde.team~wiki";
include __DIR__.'/../header.php';
// show a single page ?> // show a single page ?>
<a href="/wiki/">&lt; ~wiki</a> <a href="/wiki/">&lt; ~wiki</a>
<hr> <hr>
<?=$parser->parse(file_get_contents("pages/{$_GET['page']}.md"))->getContent()?> <?=$pg->getContent()?>
<hr> <hr>
<a href="https://git.tilde.team/meta/site/src/branch/master/wiki/pages/<?=$_GET["page"]?>.md"> <a href="https://git.tilde.team/meta/site/src/branch/master/wiki/pages/<?=$_GET["page"]?>.md">
<i class="fa fa-edit"></i> source <i class="fa fa-edit"></i> source

View File

@ -1,7 +1,7 @@
--- ---
author: ~ben author: ~ben
published: true published: true
title: getting-started title: getting started
category: category:
- main - main
--- ---