Add dropdowns to nav
This commit is contained in:
parent
2f8ac87c87
commit
92f24f8644
2 changed files with 26 additions and 10 deletions
|
@ -15,21 +15,13 @@
|
|||
<body>
|
||||
|
||||
<nav class="navbar navbar-expand-sm navbar-dark bg-black fixed-top">
|
||||
<a class="navbar-brand" href="{{ .Site.BaseURL }}">/home/{{ lower .Site.Title }}</a>
|
||||
<a class="navbar-brand" href="{{ .Site.BaseURL }}"><code>/home/{{ lower .Site.Title }}</code></a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item active">
|
||||
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Features</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="#">Pricing</a>
|
||||
</li>
|
||||
{{ partial "nav_pages.html" . }}
|
||||
</ul>
|
||||
|
||||
<div class="d-none d-sm-block">
|
||||
|
|
24
layouts/partials/nav_pages.html
Normal file
24
layouts/partials/nav_pages.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{{ $valid_children := where (where .Site.Pages ".Parent" "!=" nil) ".Params.hide_in_nav" "!=" "true" }}
|
||||
|
||||
{{ $home := .Site.GetPage "home" }}
|
||||
|
||||
{{ range where .Site.Pages.ByTitle "Kind" "section" }}
|
||||
{{ if eq .Parent $home }}
|
||||
{{ $sorted_pages := sort $valid_children (default "Title" .Params.sort_by) (default "asc" .Params.sort_order)}}
|
||||
{{ $children := where $sorted_pages ".Parent.UniqueID" .UniqueID }}
|
||||
<li class="nav-item{{ if $children }} dropdown{{ end }}">
|
||||
<a href="{{ .Permalink }}" class="nav-link{{ if $children }}{{ end }}"{{ if $children }} data-toggle="dropdown"{{ end }}><code>~/{{ .LinkTitle }}</code></a>
|
||||
{{ if $children }}
|
||||
<div class="dropdown-menu">
|
||||
{{ range first .Site.Params.nav_items $children }}
|
||||
<a class="dropdown-item" href="{{ .Permalink }}"><code>{{ .LinkTitle }}</code></a>
|
||||
{{ end }}
|
||||
{{ if ge (len $children) .Site.Params.nav_items }}
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item font-italic" href="{{ .Permalink }}"><code>See More</code></a>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
Loading…
Reference in a new issue