diff --git a/layouts/partials/hugopress/functions/modules.html b/layouts/partials/hugopress/functions/modules.html index cb9c658..d5e1f8a 100644 --- a/layouts/partials/hugopress/functions/modules.html +++ b/layouts/partials/hugopress/functions/modules.html @@ -8,6 +8,14 @@ {{- $nonWeighted = $nonWeighted | append . }} {{- end }} {{- end }} - {{- $modules = $weighted | append $nonWeighted }} + {{- $total := len . }} + {{- range $i, $mod := $weighted | append $nonWeighted }} + {{- $mod = merge $mod dict + "_index" $i + "_hasPrev" (ne $i 0) + "_hasNext" (lt $i (sub $total 1)) + }} + {{- $modules = $modules | append $mod }} + {{- end }} {{ end }} {{- return $modules }} diff --git a/layouts/partials/hugopress/functions/render-hooks.html b/layouts/partials/hugopress/functions/render-hooks.html index 2626149..9938e2b 100644 --- a/layouts/partials/hugopress/functions/render-hooks.html +++ b/layouts/partials/hugopress/functions/render-hooks.html @@ -1,15 +1,14 @@ {{- $name := .Name }} {{- $page := .Page }} {{- $modules := partialCached "hugopress/functions/modules" $name $name }} -{{- $idx := 0 }} {{- $total := len $modules }} {{- range $modules }} {{- $ctx := dict - "HasPrev" (ne $idx 0) - "HasNext" (lt $idx (sub $total 1)) - "Index" $idx "Page" $page "Total" $total + "HasPrev" ._hasPrev + "HasNext" ._hasNext + "Index" ._index }} {{- if site.Params.hugopress.debug }} {{- warnf "[hugopress] [%s] rendering hook: %q." .module .name }} @@ -27,5 +26,4 @@ {{- else }} {{- partial .partial $ctx }} {{- end }} - {{- $idx = add $idx 1 }} {{- end }}