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:
Jan 2022-01-13 20:29:12 +01:00 committed by GitHub
parent 063c65716b
commit f69ec4fca3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 @@
<a class="nav-link" href="#home">{{ i18n "home" }}</a>
</li>
{{ 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 }}
<li class="nav-item">
<a class="nav-link" href="#{{ partial "helpers/get-section-id.html" . }}">{{ .section.name }}</a>
</li>
{{ end }}
{{ end }}
{{- end }}
{{ if gt $sectionCount 5 }}
{{ if gt $sectionCount $maxVisibleSections }}
<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>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
@ -90,7 +91,7 @@
{{ range sort $sections "section.weight" }}
{{ if and (.section.enable) (.section.showOnNavbar) }}
{{ $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>
{{ end }}
{{ end }}