From 762db9b38ace717c98d37d7afd0cf14976d4d2a1 Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 7 Mar 2024 20:16:32 -0500 Subject: [PATCH] taxonomy-list.html: Get arguments from dictionary instead of scratch --- layouts/_default/single.html | 20 ++++++++++---------- layouts/partials/taxonomy-list.html | 17 +++++++++-------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 5e24aa5b..8e46a6f9 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -59,16 +59,16 @@ {{- $partialPath := printf "post-paginations/%s.html" .Section }} diff --git a/layouts/partials/taxonomy-list.html b/layouts/partials/taxonomy-list.html index 2a352949..4598bcb0 100644 --- a/layouts/partials/taxonomy-list.html +++ b/layouts/partials/taxonomy-list.html @@ -1,17 +1,18 @@ {{/* -Provides an element that shows all terms in a taxonomy assigned to the current -page in the context. +Provides an element that shows all terms assigned to a page in a taxonomy. -Recognized parameters in .Scratch: +The context should be a dictionary with these key-value pairs: +- page: The page whose taxonomy is to be displayed - taxonomy: The name of the taxonomy to show in the element - iconClass: The class for the icon shown for the taxonomy */}} -{{- $taxonomy := .Scratch.Get "taxonomy" }} -{{- $iconClass := .Scratch.Get "iconClass" }} +{{- $page := .page }} +{{- $taxonomy := .taxonomy }} +{{- $iconClass := .iconClass }} -{{- if index .Params $taxonomy }} -{{- $taxonomyPage := urlize $taxonomy | .Site.GetPage }} +{{- if index $page.Params $taxonomy }} +{{- $taxonomyPage := urlize $taxonomy | site.GetPage }} {{- $scratch := newScratch }} {{- range $taxonomyPage.Data.Terms }} {{- $scratch.SetInMap "taxonomyHomes" .Page.Title .Page.RelPermalink }} @@ -23,7 +24,7 @@ {{ $taxonomyPage.Title }}{{ i18n "punctuationColon" | safeHTML }} - {{- range $i, $term := index .Params $taxonomy }} + {{- range $i, $term := index $page.Params $taxonomy }} {{- if gt $i 0 -}} {{- i18n "punctuationCommaInList" | safeHTML -}}