pages marked as menu items render as non-blog pages

pull/84/head
Ro 3 years ago
parent 7775c1d409
commit dad43f4a19

@ -63,17 +63,24 @@ class IndexControl
break; break;
default: default:
//check layout to see what page should be rendered //check if page is a menu item, if not render along path as usual
$template = $settings["global"]["theme"] . "/page.twig"; $page = [];
$book = new Book(); $book = new Book();
if (is_numeric($args["first"])) {
$page = $book->findPageBySlug($args["third"]); $page = $book->findPageBySlug($args["third"]);
} else {
$page = $book->findPageBySlug($args["first"]);
}
$template =
$settings["global"]["theme"] . "/" . $page["layout"] . ".twig";
$pageOptions = Sorting::page($page); $pageOptions = Sorting::page($page);
break; break;
} }
} else { } else {
//index //index
$template = $settings["global"]["theme"] . "/index.twig"; $template =
$settings["global"]["theme"] . "/" . $page["layout"] . ".twig";
$book = new Book(""); $book = new Book("");
$page = $book->findPageBySlug(); $page = $book->findPageBySlug();
$pageOptions = Sorting::page($page); $pageOptions = Sorting::page($page);
@ -83,6 +90,7 @@ class IndexControl
$response->getBody()->write($html); $response->getBody()->write($html);
return $response; return $response;
} else { } else {
//if dynamic flag is false, load up html
$view = Twig::fromRequest($request); $view = Twig::fromRequest($request);
$html = file_get_contents("../public/index.html"); $html = file_get_contents("../public/index.html");
$response->getBody()->write($html); $response->getBody()->write($html);

@ -79,11 +79,17 @@ class Render
if (str_contains($page["layout"], "index")) { if (str_contains($page["layout"], "index")) {
$location = "../public/index.html"; $location = "../public/index.html";
$dir = null; $dir = null;
} else {
// if page is a menu item, render the page on public root
if ($page["menu"] == "true") {
$location = "../public/" . $page["slug"] . ".html";
$dir = "../public/";
} else { } else {
$location = $location =
"../public/" . $page["path"] . "/" . $page["slug"] . ".html"; "../public/" . $page["path"] . "/" . $page["slug"] . ".html";
$dir = "../public/" . $page["path"]; $dir = "../public/" . $page["path"];
} }
}
$html = $this->twig->render($template, $pageOptions); $html = $this->twig->render($template, $pageOptions);
DocTools::writeHTML($location, $html, $dir); DocTools::writeHTML($location, $html, $dir);

@ -181,7 +181,11 @@ class Sorting
$limit = 4; $limit = 4;
$pages = (new Book())->getContents(); $pages = (new Book())->getContents();
foreach ($pages as $item) { foreach ($pages as $item) {
if (!$item["deleted"] && $item["published"]) { if (
!$item["deleted"] &&
$item["published"] &&
$item["menu"] != "true"
) {
if (count($recent) < $limit) { if (count($recent) < $limit) {
array_push($recent, [ array_push($recent, [
"path" => $item["path"], "path" => $item["path"],

@ -36,12 +36,12 @@
{% for link in menu %} {% for link in menu %}
{% if dynamicRender is defined %} {% if dynamicRender is defined %}
{% if dynamicRender == 'true' %} {% if dynamicRender == 'true' %}
<a href="{{"/"~link.path~"/"~link.slug}}" class="menu-link">{{link.title}}</a><br /> <a href="{{"/"~link.slug}}" class="menu-link">{{link.title}}</a><br />
{% else %} {% else %}
<a href="{{"/"~link.path~"/"~link.slug~".html"}}" class="menu-link">{{link.title}}</a><br /> <a href="{{"/"~link.slug~".html"}}" class="menu-link">{{link.title}}</a><br />
{% endif %} {% endif %}
{% else %} {% else %}
<a href="{{"/"~link.path~"/"~link.slug~".html"}}" class="menu-link">{{link.title}}</a><br /> <a href="{{"/"~link.slug~".html"}}" class="menu-link">{{link.title}}</a><br />
{% endif %} {% endif %}
{% endfor %} {% endfor %}

Loading…
Cancel
Save