Clean up navbar code more
This commit is contained in:
parent
8f80a63f5c
commit
c9c90eea4b
3 changed files with 48 additions and 29 deletions
|
@ -1,37 +1,15 @@
|
|||
|
||||
<header id="header" {{ if .IsHome }}class="alt"{{ end }}>
|
||||
<h1><a href="/" class="navbar-brand">{{ title .Site.Title }}</a></h1>
|
||||
<nav id="nav">
|
||||
<ul>
|
||||
{{ $home := .Site.GetPage "home" }}
|
||||
{{ range where .Site.Pages.ByTitle "Kind" "section" }}
|
||||
{{ if eq .Parent $home }}
|
||||
{{ $sorted_pages := sort .Site.Pages (default "Title" .Params.sort_by) (default "asc" .Params.sort_order)}}
|
||||
{{ $valid_children := where $sorted_pages ".Parent" "!=" nil }}
|
||||
{{ $children := where $valid_children ".Parent.UniqueID" .UniqueID }}
|
||||
{{ $children := where $children ".Params.hide_in_nav" "!=" "true" }}
|
||||
<li class="top-level">
|
||||
{{ partial "navbar/link-item.html" . }}
|
||||
{{ if $children }}
|
||||
<ul>
|
||||
{{ range first .Site.Params.nav_items $children }}
|
||||
<li>
|
||||
{{ partial "navbar/link-item.html" . }}
|
||||
<ul>{{ range .Pages }}<li>{{ partial "navbar/link-item.html" . }}</li>{{ end }}</ul>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ if ge (len $children) .Site.Params.nav_items }}
|
||||
<li><a href="{{ .Permalink }}"><i>See more</i></a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ partial "navbar/sections.html" . }}
|
||||
|
||||
{{ range where .Site.Pages.ByTitle "Kind" "page" }}
|
||||
{{ if eq .Section "" }}<li class="top-level">{{ partial "navbar/link-item.html" . }}</li>{{ end }}
|
||||
{{ end }}
|
||||
<li class="top-level"><a class="show-mobile" href="/">Home</a></li>
|
||||
{{ partial "navbar/pages.html" . }}
|
||||
|
||||
<li class="top-level">
|
||||
<a class="show-mobile" href="/">Home</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
|
7
layouts/partials/navbar/pages.html
Normal file
7
layouts/partials/navbar/pages.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{ range where .Site.Pages.ByTitle "Kind" "page" }}
|
||||
{{ if eq .Section "" }}
|
||||
<li class="top-level">
|
||||
{{ partial "navbar/link-item.html" . }}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
34
layouts/partials/navbar/sections.html
Normal file
34
layouts/partials/navbar/sections.html
Normal file
|
@ -0,0 +1,34 @@
|
|||
{{ $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="top-level">
|
||||
{{ partial "navbar/link-item.html" . }}
|
||||
{{ if $children }}
|
||||
<ul>
|
||||
{{ range first .Site.Params.nav_items $children }}
|
||||
<li>
|
||||
{{ partial "navbar/link-item.html" . }}
|
||||
{{ $children := where $sorted_pages ".Parent.UniqueID" .UniqueID }}
|
||||
{{ if $children }}
|
||||
<ul>
|
||||
{{ range first .Site.Params.nav_items $children }}<li>{{ partial "navbar/link-item.html" . }}</li>{{ end }}
|
||||
{{ if ge (len $children) .Site.Params.nav_items }}
|
||||
<li><a href="{{ .Permalink }}"><i>See more</i></a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
|
||||
{{ if ge (len $children) .Site.Params.nav_items }}
|
||||
<li><a href="{{ .Permalink }}"><i>See more</i></a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
{{ end }}
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
Loading…
Reference in a new issue