NEW FEATURE: titles
This commit is contained in:
parent
025808bbcf
commit
b9e55c554f
@ -15,6 +15,9 @@ class DefaultController extends Controller
|
|||||||
{
|
{
|
||||||
$pageRepo = new Page();
|
$pageRepo = new Page();
|
||||||
$page = $pageRepo->getPage($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']);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,10 +22,13 @@ class Page
|
|||||||
public function getPage(string $page)
|
public function getPage(string $page)
|
||||||
{
|
{
|
||||||
$return['header'] = file_get_contents(strtolower($this->root . '/_main.md'));
|
$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')) {
|
if(file_exists($this->root . '/' . $page . '.md')) {
|
||||||
|
$return['title'] = $titles[$page] ?? '';
|
||||||
$return['content'] = file_get_contents(strtolower($this->root . '/' . $page . '.md'));
|
$return['content'] = file_get_contents(strtolower($this->root . '/' . $page . '.md'));
|
||||||
$return['status'] = '200';
|
$return['status'] = '200';
|
||||||
} else {
|
} else {
|
||||||
|
$return['title'] = $titles['404'] ?? '';
|
||||||
$return['content'] = file_get_contents(strtolower($this->root . '/404.md'));
|
$return['content'] = file_get_contents(strtolower($this->root . '/404.md'));
|
||||||
$return['status'] = '404';
|
$return['status'] = '404';
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<title>Jeroen De Meerleer :: {% block title %}{% endblock %}</title>
|
<title>Jeroen De Meerleer{% if block("title") is not empty %} :: {% block title %}{% endblock %}{% endif %}</title>
|
||||||
|
|
||||||
{% block styles %}{% endblock %}
|
{% block styles %}{% endblock %}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{% extends "base.html.twig" %}
|
{% extends "base.html.twig" %}
|
||||||
{% block title %}{{ pagetitle }}{% endblock %}
|
{% block title %}{{ title }}{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<header>{{ header | markdown | raw }}</header>
|
<header>{{ header | markdown | raw }}</header>
|
||||||
<main>{{ content | markdown | raw }}</main>
|
<main>{{ content | markdown | raw }}</main>
|
||||||
|
Loading…
Reference in New Issue
Block a user