From be1e6755dadc9936dba80a7a836318782a6720cd Mon Sep 17 00:00:00 2001 From: Valere JEANTET Date: Wed, 19 Jul 2017 23:06:03 +0200 Subject: [PATCH] Feature request: Add theme setting for default sorting of menu entries #33 --- exampleSite/config.toml | 2 +- layouts/partials/menu.html | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 293c4ad7327..e229f9ce408 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -13,7 +13,7 @@ noSearch = false # default is false showVisitedLinks = true # default is false # themeStyle = "theme" # overide base css themeVariant = "" # choose theme variant "green", "gold" , "gray", "blue" (default) - +ordersectionsby = "weight" # ordersectionsby = "title" [outputs] home = [ "HTML", "RSS", "JSON"] diff --git a/layouts/partials/menu.html b/layouts/partials/menu.html index 09898fad841..8c2e1e48eba 100644 --- a/layouts/partials/menu.html +++ b/layouts/partials/menu.html @@ -85,12 +85,22 @@ {{ .Scratch.Set "pages" (.Pages | union .Sections) }} {{end}} {{ $pages := (.Scratch.Get "pages") }} + + {{if eq .Site.Params.ordersectionsby "title"}} + {{ range $pages.ByTitle }} + {{ if and .Params.hidden (not $.showhidden) }} + {{else}} + {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks }} + {{end}} + {{ end }} + {{else}} {{ range $pages.ByWeight }} {{ if and .Params.hidden (not $.showhidden) }} {{else}} {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks }} {{end}} {{ end }} + {{end}} {{ end }}