From c9c90eea4b656d04236fec5a95746e4f5ba5d7df Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sat, 23 Sep 2017 14:53:17 +0100 Subject: [PATCH] Clean up navbar code more --- layouts/partials/navbar/index.html | 36 ++++++--------------------- layouts/partials/navbar/pages.html | 7 ++++++ layouts/partials/navbar/sections.html | 34 +++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 layouts/partials/navbar/pages.html create mode 100644 layouts/partials/navbar/sections.html diff --git a/layouts/partials/navbar/index.html b/layouts/partials/navbar/index.html index 3450661..741496b 100644 --- a/layouts/partials/navbar/index.html +++ b/layouts/partials/navbar/index.html @@ -1,37 +1,15 @@ + diff --git a/layouts/partials/navbar/pages.html b/layouts/partials/navbar/pages.html new file mode 100644 index 0000000..a1cde6e --- /dev/null +++ b/layouts/partials/navbar/pages.html @@ -0,0 +1,7 @@ +{{ range where .Site.Pages.ByTitle "Kind" "page" }} + {{ if eq .Section "" }} +
  • + {{ partial "navbar/link-item.html" . }} +
  • + {{ end }} +{{ end }} diff --git a/layouts/partials/navbar/sections.html b/layouts/partials/navbar/sections.html new file mode 100644 index 0000000..e8b0087 --- /dev/null +++ b/layouts/partials/navbar/sections.html @@ -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 }} +
  • + {{ partial "navbar/link-item.html" . }} + {{ if $children }} + + {{ end }} +
  • + {{ end }} +{{ end }}