From a0c527078cb6ede755e75333d987fa49057d4919 Mon Sep 17 00:00:00 2001 From: "E. S." Date: Tue, 5 Nov 2024 04:02:50 +0300 Subject: [PATCH] page: render breadbrumbs if parent page is specified --- handler/MainHandler.php | 15 +++++++++++++++ htdocs/scss/app/blog.scss | 6 +++--- skin/main.phps | 3 ++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/handler/MainHandler.php b/handler/MainHandler.php index 3e582f6..1bc4641 100644 --- a/handler/MainHandler.php +++ b/handler/MainHandler.php @@ -53,16 +53,31 @@ class MainHandler extends request_handler { else if ($page->shortName == 'notes') set_skin_opts(['head_section' => $page->shortName]); + $bc = null; if ($page) { add_meta([ '$url' => 'https://'.$config['domain'].$page->getUrl(), '$title' => $page->title, ]); + + if ($page->parentId) { + $bc = []; + $parent = $page; + while ($parent?->parentId) { + $parent = pages::getById($parent->parentId); + if ($parent) + $bc[] = ['url' => $parent->getUrl(), 'text' => $parent->title]; + } + if (empty($bc)) + $bc = null; + } } + set_title($page ? $page->title : '???'); render('main/page', unsafe_html: $page->getHtml(is_retina(), getUserTheme()), page_url: $page->getUrl(), + bc: $bc, short_name: $page->shortName); not_found(); diff --git a/htdocs/scss/app/blog.scss b/htdocs/scss/app/blog.scss index 96e97de..8487246 100644 --- a/htdocs/scss/app/blog.scss +++ b/htdocs/scss/app/blog.scss @@ -316,7 +316,7 @@ body.wide .blog-post { h1 { margin: 35px 0 16px; font-weight: 600; - font-size: 25px; + font-size: 22px; border-bottom: 1px $border-color solid; padding-bottom: 6px; } @@ -324,14 +324,14 @@ body.wide .blog-post { h2 { margin: 35px 0 16px; font-weight: 500; - font-size: 25px; + font-size: 22px; border-bottom: 1px $border-color solid; padding-bottom: 6px; } h3 { margin: 27px 0 16px; - font-size: 24px; + font-size: 20px; font-weight: 500; } diff --git a/skin/main.phps b/skin/main.phps index 783bd9e..ee49389 100644 --- a/skin/main.phps +++ b/skin/main.phps @@ -159,9 +159,10 @@ function articles_right_link($ctx, $url, string $label, int $index) { // any page // -------- -function page($ctx, $page_url, $short_name, $unsafe_html) { +function page($ctx, $page_url, $short_name, $unsafe_html, $bc) { $html = << + {$ctx->if_true($bc, fn() => $ctx->bc($bc))} {$ctx->if_admin($ctx->page_admin_links, $page_url, $short_name)}
{$unsafe_html}