diff --git a/src/Controller/DefaultController.php b/src/Controller/DefaultController.php index daf94bd..576bad5 100644 --- a/src/Controller/DefaultController.php +++ b/src/Controller/DefaultController.php @@ -15,6 +15,9 @@ class DefaultController extends Controller { $pageRepo = new Page(); $page = $pageRepo->getPage($page); - return $this->render('/page.html.twig', ['header' => $page['header'], 'content' => $page['content']], $page['status']); + return $this->render('/page.html.twig', [ + 'header' => $page['header'], + 'content' => $page['content'], + 'title' => $page['title']], $page['status']); } } \ No newline at end of file diff --git a/src/Repository/Page.php b/src/Repository/Page.php index e282483..637068b 100644 --- a/src/Repository/Page.php +++ b/src/Repository/Page.php @@ -22,10 +22,13 @@ class Page public function getPage(string $page) { $return['header'] = file_get_contents(strtolower($this->root . '/_main.md')); + $titles = json_decode(file_get_contents($this->root . '/titles.json'), true); if(file_exists($this->root . '/' . $page . '.md')) { + $return['title'] = $titles[$page] ?? ''; $return['content'] = file_get_contents(strtolower($this->root . '/' . $page . '.md')); $return['status'] = '200'; } else { + $return['title'] = $titles['404'] ?? ''; $return['content'] = file_get_contents(strtolower($this->root . '/404.md')); $return['status'] = '404'; } diff --git a/templates/base.html.twig b/templates/base.html.twig index 4dd955a..25e6dc6 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -3,7 +3,7 @@
-