From 50565f968333204c5bb5513a32a7e804dfd82e44 Mon Sep 17 00:00:00 2001 From: Will Faught Date: Sun, 8 Jan 2023 00:30:49 -0800 Subject: [PATCH] Add image_raw, image_stretch, image_url params to home.html --- README.md | 7 ++--- exampleSite/content/_index.md | 3 ++- layouts/_default/home.html | 40 ++++++++++++++--------------- layouts/partials/paige/img.html | 12 ++++++--- layouts/partials/paige/link.html | 6 ++--- layouts/partials/paige/links.html | 6 ++--- layouts/partials/paige/script.html | 6 ++--- layouts/partials/paige/scripts.html | 6 ++--- 8 files changed, 45 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index a06278ef..fa4aba65 100644 --- a/README.md +++ b/README.md @@ -318,9 +318,10 @@ Additional optional home page parameters: ```yaml blurb: "There's a new daddy in town." # Displayed below the greeting -center_url: "my-center.jpg" # An image that is centered -greeting: "You know best" # Displayed below the center and stretch images -stretch_url: "my-stretch.jpg" # A 4x3 or panorama image that is stretched fully horizontally +greeting: "You know best" # Displayed below the image +image_raw: true # Do not copy or process the image +image_stretch: true # Stretch the image fully horizontally if true; center the image otherwise +image_url: "me.jpg" # A page, site, or remote resource glob ``` Additional optional list page parameters: diff --git a/exampleSite/content/_index.md b/exampleSite/content/_index.md index dc38e967..b80d4d1b 100644 --- a/exampleSite/content/_index.md +++ b/exampleSite/content/_index.md @@ -2,7 +2,8 @@ blurb: There's a new daddy in town. A discipline daddy. If I make this comeback, I'll buy you a hundred George Michaels that you can teach to drive! These are my awards, Mother. From Army. The seal is for marksmanship, and the gorilla is for sand racing. We'll have to find something to do so that people can look at you without wanting to kill [themselves](https://bluthipsum.com). description: Go ahead, touch the Cornballer greeting: You know [best](https://www.youtube.com/watch?v=1WDW8XKEGgU) -stretch_url: stretch.webp +image_stretch: true +image_url: stretch.webp title: No Borders, No Limits --- diff --git a/layouts/_default/home.html b/layouts/_default/home.html index c4a2b845..3cbe6df4 100644 --- a/layouts/_default/home.html +++ b/layouts/_default/home.html @@ -2,27 +2,25 @@
{{ partial "paige/metadata.html" . }}
- {{ with .Params.stretch_url }} -

- {{ partial "paige/img.html" (dict - "class" "mw-100 rounded-4 shadow" - "fetchpriority" "high" - "loading" "eager" - "src" . - "style" "height: 20rem; object-fit: cover; width: 100%" - ) }} -

- {{ end }} - {{ with .Params.center_url }} -

- {{ partial "paige/img.html" (dict - "class" "mw-100 rounded-4 shadow" - "fetchpriority" "high" - "loading" "eager" - "src" . - "style" "height: 20rem" - ) }} -

+ {{ if .Params.image_url }} + {{ $class := "mw-100 rounded-4 shadow" }} + {{ if .Params.image_stretch }} + {{ $class = "rounded-4 shadow w-100" }} + {{ end }} + {{ $style := "height: 20rem" }} + {{ if .Params.image_stretch }} + {{ $style = "height: 20rem; object-fit: cover" }} + {{ end }} +

+ {{ partial "paige/img.html" (dict + "class" $class + "fetchpriority" "high" + "loading" "eager" + "raw" .Params.image_raw + "src" .Params.image_url + "style" $style + ) }} +

{{ end }} {{ with .Params.greeting }}

{{ . | markdownify }}

diff --git a/layouts/partials/paige/img.html b/layouts/partials/paige/img.html index 59b29ef7..76c5c805 100644 --- a/layouts/partials/paige/img.html +++ b/layouts/partials/paige/img.html @@ -2,26 +2,27 @@ {{ $class := .class }} {{ $crossorigin := .crossorigin | default "anonymous" }} {{ $fetchpriority := .fetchpriority }} +{{ $fingerprint := .fingerprint | default true }} {{ $height := .height }} {{ $loading := .loading | default "lazy" }} {{ $method := .method }} {{ $options := .options }} {{ $page := .page }} +{{ $raw := .raw }} {{ $referrerpolicy := .referrerpolicy | default "no-referrer" }} -{{ $remote := .remote }} {{ $resource := .resource }} {{ $src := .src }} {{ $style := .style }} {{ $title := .title }} {{ $width := .width }} -{{ if $remote }} +{{ if $raw }} {{ $src = relLangURL $src }} {{ else }} {{ if not $resource }} {{ $resource = partial "paige/func-resource.html" (dict "page" $page - "url" $src + "url" (relLangURL $src) ) }} {{ end }} {{ if and $method $options }} @@ -37,7 +38,10 @@ {{ errorf "invalid method: %q" $method }} {{ end }} {{ end }} - {{ $src = ($resource | fingerprint).RelPermalink }} + {{ if $fingerprint }} + {{ $resource = $resource | fingerprint }} + {{ end }} + {{ $src = $resource.RelPermalink }} {{ end }} {{ . }} diff --git a/layouts/partials/paige/link.html b/layouts/partials/paige/link.html index 6e1ed639..80415774 100644 --- a/layouts/partials/paige/link.html +++ b/layouts/partials/paige/link.html @@ -2,15 +2,15 @@ {{ $href := .href }} {{ $integrity := .integrity }} {{ $page := .page }} +{{ $raw := .raw }} {{ $referrerpolicy := .referrerpolicy | default "no-referrer" }} -{{ $remote := .remote }} -{{ if $remote }} +{{ if $raw }} {{ $href = relLangURL $href }} {{ else }} {{ $resource := (partial "paige/func-resource.html" (dict "page" $page - "url" $href + "url" (relLangURL $href) )) | minify | fingerprint }} {{ $href = $resource.RelPermalink }} {{ $integrity = $resource.Data.Integrity }} diff --git a/layouts/partials/paige/links.html b/layouts/partials/paige/links.html index 9bb89322..8a9dd7ec 100644 --- a/layouts/partials/paige/links.html +++ b/layouts/partials/paige/links.html @@ -11,18 +11,18 @@ {{ partial "paige/link.html" (dict "href" (.Site.Params.paige.bootstrap.icons.link_href | default "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.3/font/bootstrap-icons.css") "integrity" .Site.Params.paige.bootstrap.icons.link_integrity - "remote" true + "raw" true ) }} {{ partial "paige/link.html" (dict "href" (.Site.Params.paige.bootstrap.style.link_href | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css") "integrity" .Site.Params.paige.bootstrap.style.link_integrity - "remote" .Site.Params.paige.bootstrap.style.remote + "raw" .Site.Params.paige.bootstrap.style.raw ) }} {{ if or .Params.paige.math (and .Params.paige.show_full_pages (where .Pages "Params.paige.math" "eq" true)) }} {{ partial "paige/link.html" (dict "href" (.Site.Params.paige.math.style.link_href | default "https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/katex.min.css") "integrity" (.Site.Params.paige.math.style.link_integrity | default "sha256-NJNVfEC6jfEt62wQMafLNT2eI6BaWONXbpkSEVAs3+8=") - "remote" true + "raw" true ) }} {{ end }} {{ if .AlternativeOutputFormats }} diff --git a/layouts/partials/paige/script.html b/layouts/partials/paige/script.html index ec375bf9..2a51668d 100644 --- a/layouts/partials/paige/script.html +++ b/layouts/partials/paige/script.html @@ -4,15 +4,15 @@ {{ $onload := .onload | safeJS }} {{ $page := .page }} {{ $referrerpolicy := .referrerpolicy | default "no-referrer" }} -{{ $remote := .remote }} +{{ $raw := .raw }} {{ $src := .src }} -{{ if $remote }} +{{ if $raw }} {{ $src = relLangURL $src }} {{ else }} {{ $resource := (partial "paige/func-resource.html" (dict "page" $page - "url" $src + "url" (relLangURL $src) )) | minify | fingerprint }} {{ $integrity = $resource.Data.Integrity }} {{ $src = $resource.RelPermalink }} diff --git a/layouts/partials/paige/scripts.html b/layouts/partials/paige/scripts.html index 4119c510..8a1df158 100644 --- a/layouts/partials/paige/scripts.html +++ b/layouts/partials/paige/scripts.html @@ -48,19 +48,19 @@ paigeQuery.addEventListener("change", function (e) { {{ partial "paige/script.html" (dict "integrity" .Site.Params.paige.bootstrap.script.script_integrity - "remote" .Site.Params.paige.bootstrap.script.remote + "raw" .Site.Params.paige.bootstrap.script.raw "src" (.Site.Params.paige.bootstrap.script.script_src | default "https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js") ) }} {{ if or .Params.paige.math (and .Params.paige.show_full_pages (where .Pages "Params.paige.math" "eq" true)) }} {{ partial "paige/script.html" (dict "integrity" .Site.Params.paige.math.script.script_integrity - "remote" .Site.Params.paige.math.script.remote + "raw" .Site.Params.paige.math.script.raw "src" (.Site.Params.paige.math.script.script_src | default "https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/katex.min.js") ) }} {{ partial "paige/script.html" (dict "integrity" .Site.Params.paige.math.autorender.script_integrity "onload" "renderMathInElement(document.body);" - "remote" .Site.Params.paige.math.autorender.remote + "raw" .Site.Params.paige.math.autorender.raw "src" (.Site.Params.paige.math.autorender.script_src | default "https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/contrib/auto-render.min.js") ) }} {{ end }}