diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-04-04 22:03:10 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-06-11 23:42:04 +0300 |
commit | a879b628240d0138641dba4ebe2273af06b02f68 (patch) | |
tree | 2f48c4028b4b8748493bd77debe72ef303758034 | |
parent | 60ce1f081af8598ecfa5007b783d2ff784c4c50f (diff) |
Render content from oldest first
To get stable IDs.
-rw-r--r-- | layouts/_default/list.html | 79 |
1 files changed, 45 insertions, 34 deletions
diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 23cb596..ee32bbe 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,41 +1,52 @@ {{ define "main" }} - {{ range .Site.RegularPages }} - {{ .Content }} - {{ end }} + {{ range .Site.RegularPages.ByWeight.Reverse }} + {{ $tmp := .Content }} + {{ end }} + {{ range .Site.RegularPages }} + {{ .Content }} + {{ end }} {{ end }} {{ define "toc" }} - <ul id="toc" class="toc-list-h1"> - {{ $maxDepth := 0 }} - {{ with $.Site.Params.maxMenuDepth }} - {{ $maxDepth = . }} - {{ else }} - {{ $maxDepth = 2 }} - {{ end }} - {{ $headers := slice }} - {{ with .Site.RegularPages }} - {{ $headers = partial "funcs/toc_from_pages" . }} - {{ end }} - {{ range $headers }} - <li> - <a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}">{{ .title }}</a> - {{ if and (ge $maxDepth 2) .sub }} - <ul class="toc-list-h2"> - {{ range .sub }} - <li> - <a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}">{{ .title }}</a> - {{ if and (ge $maxDepth 3) .sub }} - <ul class="toc-list-h3"> - {{ range .sub }} - <li><a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}">{{ .title }}</a></li> - {{ end }} - </ul> - {{ end }} - </li> - {{ end }} - </ul> + <ul id="toc" class="toc-list-h1"> + {{ $maxDepth := 0 }} + {{ with $.Site.Params.maxMenuDepth }} + {{ $maxDepth = . }} + {{ else }} + {{ $maxDepth = 2 }} + {{ end }} + {{ $headers := slice }} + {{ with .Site.RegularPages }} + {{ $headers = partial "funcs/toc_from_pages" . }} + {{ end }} + {{ range $headers }} + <li> + <a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}"> + {{ .title }} + </a> + {{ if and (ge $maxDepth 2) .sub }} + <ul class="toc-list-h2"> + {{ range .sub }} + <li> + <a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}"> + {{ .title }} + </a> + {{ if and (ge $maxDepth 3) .sub }} + <ul class="toc-list-h3"> + {{ range .sub }} + <li> + <a href="#{{ .id }}" class="toc-h{{ .level }} toc-link" data-title="{{ .title }}"> + {{ .title }} + </a> + </li> + {{ end }} + </ul> {{ end }} - </li> + </li> + {{ end }} + </ul> {{ end }} - </ul> + </li> + {{ end }} + </ul> {{ end }} |