From 693fe4b0883e281b5fe985ce3a4aee9a64987461 Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 5 Mar 2023 14:57:18 -0800 Subject: [PATCH] Remove raw param --- README.md | 4 ---- exampleSite/content/layouts/home.md | 2 -- exampleSite/content/shortcodes/image.md | 24 ------------------------ layouts/_default/paige/home.html | 1 - layouts/partials/paige/img.html | 19 +++++++++---------- layouts/partials/paige/link.html | 12 ++++-------- layouts/partials/paige/resource.html | 4 ---- layouts/partials/paige/script.html | 13 ++++--------- layouts/shortcodes/paige/image.html | 2 -- 9 files changed, 17 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index bf506a03..17a4ce43 100644 --- a/README.md +++ b/README.md @@ -315,7 +315,6 @@ paige: image: alt: "" # Image alt height: "" # CSS unit; image height - raw: false # Do not copy the file stretch: false # Stretch the image fully horizontally if true; center the image otherwise url: "" # Local or remote resource glob width: "" # CSS unit; image width @@ -456,7 +455,6 @@ The `paige/image` shortcode provides a figure with an image. maxwidth="10rem" method="resize" options="550x webp picture Lanczos" - raw=false src="me.jpg" title="My title" width="10rem" @@ -482,8 +480,6 @@ Parameters:
Optional. String. Hugo image processing method. Must be crop, fill, fit, or resize. Must be specified with options. See the methods.
options
Optional. String. Hugo image processing options. Must be specified with method. See the options.
-
raw
-
Optional. Boolean. Whether to reference an image without copying it. Default is false.
src
Required. Position 0. String. URL. Image source.
title
diff --git a/exampleSite/content/layouts/home.md b/exampleSite/content/layouts/home.md index 79dfd602..96b9fb69 100644 --- a/exampleSite/content/layouts/home.md +++ b/exampleSite/content/layouts/home.md @@ -8,7 +8,6 @@ paige: blurb: "This is the blurb." greeting: "This is the greeting" image: - raw: false stretch: false url: "landscape.webp" main: @@ -126,7 +125,6 @@ paige: blurb: "This is the blurb." greeting: "This is the greeting" image: - raw: false stretch: false url: "landscape.webp" main: diff --git a/exampleSite/content/shortcodes/image.md b/exampleSite/content/shortcodes/image.md index 4d32a471..c36f32a2 100644 --- a/exampleSite/content/shortcodes/image.md +++ b/exampleSite/content/shortcodes/image.md @@ -83,30 +83,6 @@ Result: {{< paige/image link="https://github.com/willfaught/paige" method="resize" options="550x webp picture Lanczos" src="landscape.webp" >}} -## Raw parameter - -Code: - -```go-text-template -{{}} -``` - -Result: - -{{< paige/image raw=false src="https://picsum.photos/1296/600.webp" >}} - ---- - -Code: - -```go-text-template -{{}} -``` - -Result: - -{{< paige/image raw=true src="https://picsum.photos/1296/600.webp" >}} - ## Src parameter Code: diff --git a/layouts/_default/paige/home.html b/layouts/_default/paige/home.html index e19cd640..41db6b48 100644 --- a/layouts/_default/paige/home.html +++ b/layouts/_default/paige/home.html @@ -22,7 +22,6 @@ "fetchpriority" "high" "loading" "eager" "page" $page - "raw" $page.Params.paige.home.image.raw "src" $page.Params.paige.home.image.url "style" $style ) }} diff --git a/layouts/partials/paige/img.html b/layouts/partials/paige/img.html index 39018bf1..d9d9a301 100644 --- a/layouts/partials/paige/img.html +++ b/layouts/partials/paige/img.html @@ -12,7 +12,6 @@ {{ $method := $params.method }} {{ $options := $params.options }} {{ $page := $params.page }} -{{ $raw := $params.raw }} {{ $referrerpolicy := $params.referrerpolicy | default "no-referrer" }} {{ $resource := $params.resource }} {{ $src := $params.src }} @@ -27,16 +26,14 @@ {{ $intrinsicheight := $height }} {{ $intrinsicwidth := $width }} -{{ if $raw }} - {{ $src = relLangURL $src }} -{{ else }} - {{ if not $resource }} - {{ $resource = partial "paige/resource.html" (dict - "page" $page - "url" $src - ) }} - {{ end }} +{{ if not $resource }} + {{ $resource = partial "paige/resource.html" (dict + "page" $page + "url" $src + ) }} +{{ end }} +{{ with $resource }} {{ if and $method $options }} {{ if eq $method "crop" }} {{ $resource = $resource.Crop $options }} @@ -59,6 +56,8 @@ {{ end }} {{ $src = $resource.RelPermalink }} +{{ else }} + {{ $src = relLangURL $src }} {{ end }} {{ if and (or $height $maxheight) (not (or $maxwidth $width)) }} diff --git a/layouts/partials/paige/link.html b/layouts/partials/paige/link.html index 1dc496f5..15e99fc0 100644 --- a/layouts/partials/paige/link.html +++ b/layouts/partials/paige/link.html @@ -7,7 +7,6 @@ {{ $integrity := $params.integrity }} {{ $outputstyle := cond hugo.IsProduction "compressed" "" }} {{ $page := $params.page }} -{{ $raw := $params.raw }} {{ $referrerpolicy := $params.referrerpolicy | default "no-referrer" }} {{ $sass := $params.sass }} @@ -15,13 +14,8 @@ {{ errorf "paige/link: no href" }} {{ end }} -{{ if not $raw }} - {{ $resource := partial "paige/resource.html" (dict - "page" $page - "url" $href - ) }} - - {{ $resource = resources.ExecuteAsTemplate $href (or $page dict) $resource }} +{{ with partial "paige/resource.html" (dict "page" $page "url" $href) }} + {{ $resource := resources.ExecuteAsTemplate $href (or $page dict) . }} {{ if $sass }} {{ $resource = $resource | toCSS (dict @@ -34,6 +28,8 @@ {{ $resource = $resource | minify | fingerprint }} {{ $href = $resource.RelPermalink }} {{ $integrity = $resource.Data.Integrity }} +{{ else }} + {{ $href = relLangURL $href }} {{ end }} diff --git a/layouts/partials/paige/resource.html b/layouts/partials/paige/resource.html index 30adb100..e5974c7b 100644 --- a/layouts/partials/paige/resource.html +++ b/layouts/partials/paige/resource.html @@ -35,8 +35,4 @@ {{ end }} {{ end }} -{{ if not $result }} - {{ errorf "paige/resource: invalid resource: %q" $url }} -{{ end }} - {{ return $result }} diff --git a/layouts/partials/paige/script.html b/layouts/partials/paige/script.html index 8720a92b..bebb237a 100644 --- a/layouts/partials/paige/script.html +++ b/layouts/partials/paige/script.html @@ -6,23 +6,18 @@ {{ $onload := $params.onload | safeJS }} {{ $page := $params.page }} {{ $referrerpolicy := $params.referrerpolicy | default "no-referrer" }} -{{ $raw := $params.raw }} {{ $src := $params.src }} {{ if not $src }} {{ errorf "paige/script: no src" }} {{ end }} -{{ if $raw }} - {{ $src = $src }} -{{ else }} - {{ $resource := (partial "paige/resource.html" (dict - "page" $page - "url" $src - )) | minify | fingerprint }} - +{{ with partial "paige/resource.html" (dict "page" $page "url" $src) }} + {{ $resource := . | minify | fingerprint }} {{ $integrity = $resource.Data.Integrity }} {{ $src = $resource.RelPermalink }} +{{ else }} + {{ $href = relLangURL $href }} {{ end }} diff --git a/layouts/shortcodes/paige/image.html b/layouts/shortcodes/paige/image.html index b82bfa94..37697ff3 100644 --- a/layouts/shortcodes/paige/image.html +++ b/layouts/shortcodes/paige/image.html @@ -5,7 +5,6 @@ {{ $maxwidth := .Get "maxwidth" }} {{ $method := .Get "method" }} {{ $options := .Get "options" }} -{{ $raw := .Get "raw" }} {{ $src := .Get 0 | default (.Get "src") }} {{ $title := .Get "title" }} {{ $width := .Get "width" }} @@ -23,7 +22,6 @@ "method" $method "options" $options "page" .Page - "raw" $raw "src" $src "title" $title "width" $width