From f69ec4fca386870ad97bb13662c9a44b3f8a5dae Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 13 Jan 2022 20:29:12 +0100 Subject: [PATCH] configurable navbar item count (#493) * configurable navbar item count Make the number of navbar items outside "More" configurable via ``` config.yaml --- params: features: maxnavitems: 6 ``` * fix configurable navbar count replace all evidences of "5" by $maxnavitems * Move `features.maxnavitems` into `topNavbar.maxVisibleSections` Signed-off-by: hossainemruz Co-authored-by: Emruz Hossain --- layouts/partials/navigators/navbar.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/layouts/partials/navigators/navbar.html b/layouts/partials/navigators/navbar.html index ed6cff9..33552a4 100644 --- a/layouts/partials/navigators/navbar.html +++ b/layouts/partials/navigators/navbar.html @@ -1,6 +1,7 @@ {{/* variables for enabling/disabling various features */}} {{ $blogEnabled := site.Params.features.blog.enable | default false }} {{ $notesEnabled := site.Params.features.notes.enable | default false }} +{{ $maxVisibleSections := site.Params.topNavbar.maxVisibleSections | default 5 }} {{/* keep backward compatibility for blog post */}} {{ if site.Params.enableBlogPost }} @@ -71,18 +72,18 @@ {{ i18n "home" }} {{ if $sections }} - {{ $sectionCount := 0}} + {{ $sectionCount := 1 }} {{ range sort $sections "section.weight" }} {{ if and (.section.enable) (.section.showOnNavbar)}} {{ $sectionCount = add $sectionCount 1}} - {{ if le $sectionCount 5 }} + {{ if le $sectionCount $maxVisibleSections }} {{ end }} {{ end }} {{- end }} - {{ if gt $sectionCount 5 }} + {{ if gt $sectionCount $maxVisibleSections }}