site/layouts: add cluster to partialCached key

When we cache the output of partials we get duplicate elements be-
cause both ISEAL and FSC have "Scope", "Certificate", etc modules.
We need to use the cluster as an extra key for the partial cache
so these don't overlap.

See: https://gohugo.io/functions/partialcached/
This commit is contained in:
Alan Orth 2022-02-06 21:30:25 +03:00
parent baa22a7afc
commit 1678ec077e
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 17 additions and 8 deletions

View File

@ -33,12 +33,13 @@
{{/* it in the range below. */}}
{{ $context := . }}
{{ .Scratch.Set "cluster" "Fsc" }}
{{ $cluster := "Fsc" }}
{{ .Scratch.Set "cluster" $cluster }}
{{ $modules := slice "Assurance" "Certificate" "Coverage" "Evaluation" "Form" "Scope" "Status" }}
{{ range $modules }}
{{ $module := . }}
{{ $.Scratch.Set "module" $module }}
{{ partialCached "module-elements.html" $context $module }}
{{ partialCached "module-elements.html" $context $cluster $module }}
{{ end }}
<h2 id="download">Download</h2>

View File

@ -90,32 +90,40 @@
<h3 id="cluster-global">Global Cluster</h3>
{{ .Scratch.Set "cluster" "Global" }}
{{ $cluster := "Global" }}
{{ .Scratch.Set "cluster" $cluster }}
{{ $modules := slice "Coverage" "Form" "Provenance" "Scope" "Status" }}
{{ range $modules }}
{{ $module := . }}
{{ $.Scratch.Set "module" $module }}
{{ partialCached "module-elements.html" $context $module }}
{{/* Call the partial template to render the module's elements. */}}
{{/* Note that we need to use the $cluster and the $module as */}}
{{/* keys to the partial's cache so the cache is unique (so we */}}
{{/* don't get FSC elements in the ISEAL layout). */}}
{{ partialCached "module-elements.html" $context $cluster $module }}
{{ end }}
<h3 id="cluster-certification">Certification Cluster</h3>
{{ .Scratch.Set "cluster" "Certification" }}
{{ $cluster := "Certification" }}
{{ .Scratch.Set "cluster" $cluster }}
{{ $modules := slice "Certificate" "Certificate Holder, Owner or Certified organization" "Certified Resource or Site" "Certifying Body" }}
{{ range $modules }}
{{ $module := . }}
{{ $.Scratch.Set "module" $module }}
{{ partialCached "module-elements.html" $context $module }}
{{ partialCached "module-elements.html" $context $cluster $module }}
{{ end }}
<h3 id="cluster-impact">Impact Cluster</h3>
{{ .Scratch.Set "cluster" "Impact" }}
{{ $cluster := "Impact" }}
{{ .Scratch.Set "cluster" $cluster }}
{{ $modules := slice "Evaluation" }}
{{ range $modules }}
{{ $module := . }}
{{ $.Scratch.Set "module" $module }}
{{ partialCached "module-elements.html" $context $module }}
{{ partialCached "module-elements.html" $context $cluster $module }}
{{ end }}
<h2 id="download">Download</h2>