Browse Source

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>
Jan 3 years ago
parent
commit
f69ec4fca3
1 changed files with 5 additions and 4 deletions
  1. 5 4
      layouts/partials/navigators/navbar.html

+ 5 - 4
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 @@
           <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 }}