From 9f18874c4cf689efae8c5431ac92aa21f076f60e Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 23 Apr 2023 21:42:58 -0700 Subject: [PATCH] Remove page param from resource.html --- layouts/partials/paige/image.html | 2 +- layouts/partials/paige/link.html | 5 ++--- layouts/partials/paige/resource.html | 11 ++++------- layouts/partials/paige/script.html | 3 +-- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/layouts/partials/paige/image.html b/layouts/partials/paige/image.html index 0919cea8..7777b768 100644 --- a/layouts/partials/paige/image.html +++ b/layouts/partials/paige/image.html @@ -60,7 +60,7 @@ {{ $style = delimit $style "; " }} {{ if and (not $resource) $src }} - {{ $resource = partial "paige/resource.html" (dict "page" page "url" $src) }} + {{ $resource = partial "paige/resource.html" $src }} {{ end }} {{ if $resource }} diff --git a/layouts/partials/paige/link.html b/layouts/partials/paige/link.html index eb23c308..43ea007b 100644 --- a/layouts/partials/paige/link.html +++ b/layouts/partials/paige/link.html @@ -4,7 +4,6 @@ {{ $href := $params.href }} {{ $includepaths := $params.includepaths }} {{ $integrity := $params.integrity }} -{{ $page := $params.page }} {{ $referrerpolicy := $params.referrerpolicy | default "no-referrer" }} {{ $sass := $params.sass }} {{ $template := $params.template }} @@ -16,11 +15,11 @@ {{ errorf "paige/link: no href" }} {{ end }} -{{ with partial "paige/resource.html" (dict "page" $page "url" $href) }} +{{ with partial "paige/resource.html" $href }} {{ $resource := . }} {{ if $template }} - {{ $context := dict "color" ($page.Param "paige.color" | default "#0d6efd") }} + {{ $context := dict "color" (page.Param "paige.color" | default "#0d6efd") }} {{ $split := path.Split $href }} {{ $join := path.Join $split.Dir (print (printf "%#v" $context | sha1) "-" $split.File) }} {{ $resource = resources.ExecuteAsTemplate $join $context . }} diff --git a/layouts/partials/paige/resource.html b/layouts/partials/paige/resource.html index e5974c7b..da345850 100644 --- a/layouts/partials/paige/resource.html +++ b/layouts/partials/paige/resource.html @@ -1,7 +1,4 @@ -{{ $params := . }} - -{{ $page := $params.page }} -{{ $url := $params.url }} +{{ $url := . }} {{ $result := "" }} @@ -15,11 +12,11 @@ {{ end }} {{ end }} -{{ if and (not $result) $page }} - {{ with $page.Resources.GetMatch $url }} +{{ if and (not $result) page }} + {{ with page.Resources.GetMatch $url }} {{ $result = . }} {{ else }} - {{ with $page.Resources.Get $url }} + {{ with page.Resources.Get $url }} {{ $result = . }} {{ end }} {{ end }} diff --git a/layouts/partials/paige/script.html b/layouts/partials/paige/script.html index babce333..2362456e 100644 --- a/layouts/partials/paige/script.html +++ b/layouts/partials/paige/script.html @@ -4,7 +4,6 @@ {{ $defer := $params.defer | default "defer" }} {{ $integrity := $params.integrity }} {{ $onload := $params.onload | safeJS }} -{{ $page := $params.page }} {{ $referrerpolicy := $params.referrerpolicy | default "no-referrer" }} {{ $src := $params.src }} {{ $type := $params.type }} @@ -13,7 +12,7 @@ {{ errorf "paige/script: no src" }} {{ end }} -{{ with partial "paige/resource.html" (dict "page" $page "url" $src) }} +{{ with partial "paige/resource.html" $src }} {{ $resource := . | minify | fingerprint }} {{ $integrity = $resource.Data.Integrity }} {{ $src = $resource.RelPermalink }}