Browse Source

Find first section for chevron navigation (#26)

* Find first section for chevron navigation

* Handle disabled section

Co-authored-by: hossainemruz <emruz@appscode.com>
Jason Tipton 4 years ago
parent
commit
8658773212
2 changed files with 6 additions and 3 deletions
  1. 5 2
      layouts/partials/home.html
  2. 1 1
      layouts/partials/navbar.html

+ 5 - 2
layouts/partials/home.html

@@ -25,7 +25,10 @@
       <li>{{ . }}</li>
       <li>{{ . }}</li>
       {{ end }}
       {{ end }}
     </ul>
     </ul>
-    <!-- @todo this section should go to the first section, not necessarily about -->
-    <a href="#about"><i class="arrow bounce fa fa-chevron-down"></i></a>
+    {{ if .Site.Data.sections }}
+      {{ range first 1 (where (sort .Site.Data.sections "section.weight") ".section.enable" true) }}
+        <a href="#{{ replace (lower .section.name) " " "-" }}"><i class="arrow bounce fa fa-chevron-down"></i></a>
+      {{ end }}
+    {{ end }}
   </div>
   </div>
 </div>
 </div>

+ 1 - 1
layouts/partials/navbar.html

@@ -21,7 +21,7 @@
         </li>
         </li>
         {{- if .Site.Data.sections }}
         {{- if .Site.Data.sections }}
           {{- range sort .Site.Data.sections "section.weight" }}
           {{- range sort .Site.Data.sections "section.weight" }}
-            {{ if .section.showOnNavbar }}
+            {{ if (and .section.enable .section.showOnNavbar) }}
               <li class="nav-item">
               <li class="nav-item">
                 <a class="nav-link smooth-scroll" href="#{{ replace (lower .section.name) " " "-" }}">{{ .section.name }}</a>
                 <a class="nav-link smooth-scroll" href="#{{ replace (lower .section.name) " " "-" }}">{{ .section.name }}</a>
               </li>
               </li>