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 <hossainemruz@gmail.com>
Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
{{/* variables for enabling/disabling various features */}}
|
{{/* variables for enabling/disabling various features */}}
|
||||||
{{ $blogEnabled := site.Params.features.blog.enable | default false }}
|
{{ $blogEnabled := site.Params.features.blog.enable | default false }}
|
||||||
{{ $notesEnabled := site.Params.features.notes.enable | default false }}
|
{{ $notesEnabled := site.Params.features.notes.enable | default false }}
|
||||||
|
{{ $maxVisibleSections := site.Params.topNavbar.maxVisibleSections | default 5 }}
|
||||||
|
|
||||||
{{/* keep backward compatibility for blog post */}}
|
{{/* keep backward compatibility for blog post */}}
|
||||||
{{ if site.Params.enableBlogPost }}
|
{{ if site.Params.enableBlogPost }}
|
||||||
@@ -71,18 +72,18 @@
|
|||||||
<a class="nav-link" href="#home">{{ i18n "home" }}</a>
|
<a class="nav-link" href="#home">{{ i18n "home" }}</a>
|
||||||
</li>
|
</li>
|
||||||
{{ if $sections }}
|
{{ if $sections }}
|
||||||
{{ $sectionCount := 0}}
|
{{ $sectionCount := 1 }}
|
||||||
{{ range sort $sections "section.weight" }}
|
{{ range sort $sections "section.weight" }}
|
||||||
{{ if and (.section.enable) (.section.showOnNavbar)}}
|
{{ if and (.section.enable) (.section.showOnNavbar)}}
|
||||||
{{ $sectionCount = add $sectionCount 1}}
|
{{ $sectionCount = add $sectionCount 1}}
|
||||||
{{ if le $sectionCount 5 }}
|
{{ if le $sectionCount $maxVisibleSections }}
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>
|
<a class="nav-link" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>
|
||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{ if gt $sectionCount 5 }}
|
{{ if gt $sectionCount $maxVisibleSections }}
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{i18n "more" }}</a>
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{i18n "more" }}</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
@@ -90,7 +91,7 @@
|
|||||||
{{ range sort $sections "section.weight" }}
|
{{ range sort $sections "section.weight" }}
|
||||||
{{ if and (.section.enable) (.section.showOnNavbar) }}
|
{{ if and (.section.enable) (.section.showOnNavbar) }}
|
||||||
{{ $sectionCount = add $sectionCount 1}}
|
{{ $sectionCount = add $sectionCount 1}}
|
||||||
{{ if gt $sectionCount 5 }}
|
{{ if gt $sectionCount $maxVisibleSections }}
|
||||||
<a class="dropdown-item" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>
|
<a class="dropdown-item" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
Reference in New Issue
Block a user