From a83f339dc8923ce79280c7749e956a222a76369b Mon Sep 17 00:00:00 2001 From: Ben Goldsworthy Date: Wed, 4 Jun 2025 20:54:29 +0200 Subject: [PATCH] use `safeJS` --- .../scripts/{charts.html => charts.js} | 0 ...map.html => show_post_locations_on_map.js} | 0 layouts/partials/single/footer-scripts.html | 52 +++++++++++-------- 3 files changed, 31 insertions(+), 21 deletions(-) rename layouts/partials/scripts/{charts.html => charts.js} (100%) rename layouts/partials/scripts/{show_post_locations_on_map.html => show_post_locations_on_map.js} (100%) diff --git a/layouts/partials/scripts/charts.html b/layouts/partials/scripts/charts.js similarity index 100% rename from layouts/partials/scripts/charts.html rename to layouts/partials/scripts/charts.js diff --git a/layouts/partials/scripts/show_post_locations_on_map.html b/layouts/partials/scripts/show_post_locations_on_map.js similarity index 100% rename from layouts/partials/scripts/show_post_locations_on_map.html rename to layouts/partials/scripts/show_post_locations_on_map.js diff --git a/layouts/partials/single/footer-scripts.html b/layouts/partials/single/footer-scripts.html index f46d86c..c544b2e 100644 --- a/layouts/partials/single/footer-scripts.html +++ b/layouts/partials/single/footer-scripts.html @@ -1,46 +1,56 @@ {{- /* - Renders a single item's required footer JS scripts. + Renders a single item's required footer JS scripts. - @params sc Site context. - @params pc Page context. - */ + @params sc Site context. + @params pc Page context. + */ -}} + {{- if ( not ( isset . "sc" ) ) -}} - {{- errorf "No site context passed" -}} + {{- errorf "No site context passed" -}} {{- end -}} {{- if ( not ( isset . "pc" ) ) -}} - {{- errorf "No page context passed" -}} + {{- errorf "No page context passed" -}} {{- end -}} {{- if ( and ( .pc.HasShortcode "chart" ) ( not ( .pc.Page.Resources.GetMatch "charts-init" ) ) ) -}} - {{- errorf "No 'chart-init' page resource defined (%q)" .pc.Page.File.Path -}} + {{- errorf "No 'chart-init' page resource defined (%q)" .pc.Page.File.Path -}} {{- end -}} + {{ if .pc.Params.locations }} - {{- - partialCached - "scripts/show_post_locations_on_map.html" - ( dict - "pc" .pc - "locations_data" .sc.Site.Data.locations - "locations" .pc.Params.locations - ) - .pc.Params.locations + {{ end }} {{ if .pc.HasShortcode "chart" }} - {{- $configJs := ( .pc.Page.Resources.GetMatch "charts-init" | fingerprint ) -}} + {{- $configJs := ( .pc.Page.Resources.GetMatch "charts-init" | fingerprint ) -}} + {{ end }}