From 503da470df382c3ec5d0e3e62b77d6eba64dc1ce Mon Sep 17 00:00:00 2001 From: Alan Orth Date: Sun, 6 Feb 2022 20:58:42 +0300 Subject: [PATCH] site/layouts: group elements by module Group elements by module within each cluster. --- site/layouts/_default/home.html | 61 +++++++++------------- site/layouts/partials/module-elements.html | 31 +++++++++++ 2 files changed, 55 insertions(+), 37 deletions(-) create mode 100644 site/layouts/partials/module-elements.html diff --git a/site/layouts/_default/home.html b/site/layouts/_default/home.html index 05869efe..582573f3 100644 --- a/site/layouts/_default/home.html +++ b/site/layouts/_default/home.html @@ -83,54 +83,41 @@
  • Encoding: metadata should be encoded in UTF-8 to ensure correct representation of international characters.
  • Applicability: metadata should describe what the item is, not what it isn't. If a metadata element is not applicable you should not use it. Do not enter "N/A"!
  • + + {{/* Assign the current page context to a variable so we don't lose */}} + {{/* it in the range below. */}} + {{ $context := . }} +

    Global Cluster

    -

    - {{/* Note: we need to use two ranges for each cluster because it is */}} - {{/* not possible to re-use Hugo's paginate object unless you use */}} - {{/* the same exact arguments each time. */}} - {{ range where (where site.RegularPages "Type" "terms") "Params.cluster" "==" "Global" }} - {{- if .Params.field -}} - {{ .Params.field }} - {{- end -}} - {{ end }} -

    - - {{ range where (where site.RegularPages "Type" "terms") "Params.cluster" "==" "Global" }} -
    - {{ .Render "term" }} -
    + {{ .Scratch.Set "cluster" "Global" }} + {{ $modules := slice "Coverage" "Form" "Provenance" "Scope" "Status" }} + {{ range $modules }} + {{ $module := . }} + {{ $.Scratch.Set "module" $module }} + {{ partialCached "module-elements.html" $context $module }} {{ end }}

    Certification Cluster

    -

    - {{ range where (where site.RegularPages "Type" "terms") "Params.cluster" "==" "Certification" }} - {{- if .Params.field -}} - {{ .Params.field }} - {{- end -}} - {{ end }} -

    - {{ range where (where site.RegularPages "Type" "terms") "Params.cluster" "==" "Certification" }} -
    - {{ .Render "term" }} -
    + {{ .Scratch.Set "cluster" "Certification" }} + {{ $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 }} {{ end }}

    Impact Cluster

    -

    - {{ range where (where site.RegularPages "Type" "terms") "Params.cluster" "==" "Impact" }} - {{- if .Params.field -}} - {{ .Params.field }} - {{- end -}} - {{ end }} -

    - {{ range where (where site.RegularPages "Type" "terms") "Params.cluster" "==" "Impact" }} -
    - {{ .Render "term" }} -
    + {{ .Scratch.Set "cluster" "Impact" }} + {{ $modules := slice "Evaluation" }} + {{ range $modules }} + {{ $module := . }} + {{ $.Scratch.Set "module" $module }} + {{ partialCached "module-elements.html" $context $module }} {{ end }} +

    Download

    The ISEAL Core schema is available for download in two formats:

    diff --git a/site/layouts/partials/module-elements.html b/site/layouts/partials/module-elements.html new file mode 100644 index 00000000..77b48eaf --- /dev/null +++ b/site/layouts/partials/module-elements.html @@ -0,0 +1,31 @@ +{{/* Retrieve the cluster and module from global scratch. */}} +{{ $cluster := $.Scratch.Get "cluster" }} +{{ $module := $.Scratch.Get "module" }} + +{{/* Note: we need to use two ranges for each module because it is */}} +{{/* not possible to re-use Hugo's paginate object unless you use */}} +{{/* the same exact arguments each time. */}} +

    {{ $module }} Module

    + + + + + + + +
    Elements in the {{- $module -}} module: + {{/* Use range over a nested where. The way to read this is */}} + {{/* from the inside out: terms, cluster, module. */}} + {{ range where (where (where site.RegularPages "Type" "terms") "Params.cluster" "==" $cluster) "Params.module" "==" $module }} + {{ .Params.field }} + {{ end }} +
    + +{{ range where (where (where site.RegularPages "Type" "terms") "Params.cluster" "==" $cluster) "Params.module" "==" $module }} +
    + {{ .Render "term" }} +
    +{{ end }} + + +{{- /* vim: set ts=2 sw=2 et: */}}