From 6b345bfa41396d2e52375aad1693c1828eba428f Mon Sep 17 00:00:00 2001 From: Marcell Mars Date: Sat, 12 Sep 2020 03:03:24 +0200 Subject: [PATCH] every Page has .Scratch *and* where could be nested... --- .../sandpoints/layouts/_default/single.html | 30 ++++++++--------- .../sandpoints/layouts/partials/header.html | 32 +++++++------------ 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/themes/sandpoints/layouts/_default/single.html b/themes/sandpoints/layouts/_default/single.html index 1b862db..e061b84 100644 --- a/themes/sandpoints/layouts/_default/single.html +++ b/themes/sandpoints/layouts/_default/single.html @@ -1,21 +1,20 @@ {{ define "main" }} {{$currentNode := . }} -{{ $graphOptions := newScratch }} {{ range $k, $v := $.Site.Data.sandpointsnamegraph }} {{ if eq (substr $currentNode.File.Dir 0 -1) $k }} - {{ $graphOptions.Set "plural" (index $v "plural") }} - {{ $graphOptions.Set "depth" (index $v "depth") }} + {{ $.Scratch.Set "plural" (index $v "plural") }} + {{ $.Scratch.Set "depth" (index $v "depth") }} {{ with index $v "in" }} - {{ $graphOptions.Set "in" (index $v "in") }} + {{ $.Scratch.Set "in" (index $v "in") }} {{ end }} {{ with index $v "has" }} - {{ $graphOptions.Set "has" (index $v "has") }} + {{ $.Scratch.Set "has" (index $v "has") }} {{ end }} {{ end }} {{ end }} -
{{ substr .File.Dir 0 -1 }}⁄{{ substr .Title 0 1 }}{{ substr .Title 1 }}
+
{{ substr .File.Dir 0 -1 }}⁄{{ substr .Title 0 1 }}{{ substr .Title 1 }}
@@ -24,26 +23,27 @@ {{ end }}
- {{ if (not (eq ($graphOptions.Get "depth") "crust")) }} + {{ if (not (eq ($.Scratch.Get "depth") "crust")) }}
- has {{ index ($graphOptions.Get "has") 1 }}⁄ + has {{ index ($.Scratch.Get "has") 1 }}⁄
- {{ range index $currentNode.Params (printf "has_%s" (index ($graphOptions.Get "has") 1) )}} - {{ with $.GetPage (printf "%s%s" (printf "/%s/" (index ($graphOptions.Get "has") 0)) . ) }} -
+ {{ range index $currentNode.Params (printf "has_%s" (index ($.Scratch.Get "has") 1) )}} + {{ with $.GetPage (printf "%s%s" (printf "/%s/" (index ($.Scratch.Get "has") 0)) . ) }} + {{ end }} {{ end }} {{ end }} - {{ if eq ($graphOptions.Get "depth") "crust" }} + {{ if eq ($.Scratch.Get "depth") "crust" }}
- in {{ index ($graphOptions.Get "in") 1 }}⁄ + in {{ index ($.Scratch.Get "in") 1 }}⁄
- {{ range where $.Site.RegularPages ".Section" (index ($graphOptions.Get "in") 0) }} - {{ if in (index .Params (printf "has_%s" ($graphOptions.Get "plural"))) $currentNode.File.LogicalName }} +
+ {{ range where $.Site.RegularPages ".Section" (index ($.Scratch.Get "in") 0) }} + {{ if in (index .Params (printf "has_%s" ($.Scratch.Get "plural"))) $currentNode.File.LogicalName }} diff --git a/themes/sandpoints/layouts/partials/header.html b/themes/sandpoints/layouts/partials/header.html index 501263a..00eadee 100644 --- a/themes/sandpoints/layouts/partials/header.html +++ b/themes/sandpoints/layouts/partials/header.html @@ -1,44 +1,36 @@ {{ $currentSession := . }} -{{ $_ := newScratch }} {{- range $k, $v := .Page.Site.Data.sandpointsnamegraph -}} {{ if eq $currentSession.File.Dir (printf "%s/" $k) }} - {{ $_.Add "depth" (index $v "depth") }} + {{ $.Scratch.Add "depth" (index $v "depth") }} {{ if eq (index $v "depth") "mantle" }} - {{ $_.Add "home" (index $v "in" 0) }} + {{ $.Scratch.Add "home" (index $v "in" 0) }} {{ end }} {{ if eq (index $v "depth") "crust" }} - {{ $_.Add "home" (index (index $currentSession.Site.Data.sandpointsnamegraph (index $v "in" 0)) "in" 0) }} - {{ $_.Add "mantle" (index $v "in" 0) }} - {{ $_.Add "mantle_has" (index (index $currentSession.Site.Data.sandpointsnamegraph (index $v "in" 0)) "has" 1) }} + {{ $.Scratch.Add "home" (index (index $currentSession.Site.Data.sandpointsnamegraph (index $v "in" 0)) "in" 0) }} + {{ $.Scratch.Add "mantle" (index $v "in" 0) }} + {{ $.Scratch.Add "mantle_has" (index (index $currentSession.Site.Data.sandpointsnamegraph (index $v "in" 0)) "has" 1) }} {{ end }} {{ end }} {{- end -}} -