diff --git a/layouts/partials/article-link/card-related.html b/layouts/partials/article-link/card-related.html index f84bdd81..f576763a 100644 --- a/layouts/partials/article-link/card-related.html +++ b/layouts/partials/article-link/card-related.html @@ -1,4 +1,3 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ with .Params.externalUrl }} {{ else }} @@ -10,30 +9,30 @@ {{- range first 6 . }} {{ end -}} {{- else -}} - {{- $images := $.Resources.ByType "image" -}} - {{- $featured := $images.GetMatch "*feature*" -}} - {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} - {{ if and .Params.featureimage (not $featured) }} - {{- $url:= .Params.featureimage -}} - {{ $featured = resources.GetRemote $url }} - {{ end }} - {{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} - {{- with $featured -}} - {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} - {{ with . }} - + {{ $images := $.Resources.ByType "image" }} + {{ $featuredImage := $images.GetMatch "*feature*" }} + {{ if not $featuredImage }} + {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} {{ end }} - {{ else }} - {{ with .Resize "600x" }} - + {{ if and (not $featuredImage) .Params.featureimage }} + {{ $featuredImage = resources.GetRemote .Params.featureimage }} + {{ end }} + {{ if not $featuredImage }} + {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} + {{ end }} + {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} + {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} + {{ $featuredImage = $featuredImage.Resize "600x" }} + {{ end }} + {{ with $featuredImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} + + {{ else }} + {{ with $.Site.Params.images }} + {{ end }} {{ end }} - {{- else -}} - {{- with $.Site.Params.images }} - {{ end -}} - {{- end -}} - {{- end -}} - + {{ end }} {{ if and .Draft .Site.Params.article.showDraftLabel }} diff --git a/layouts/partials/article-link/card.html b/layouts/partials/article-link/card.html index c876e35d..0ce06e75 100644 --- a/layouts/partials/article-link/card.html +++ b/layouts/partials/article-link/card.html @@ -1,4 +1,3 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} {{ with .Params.externalUrl }} {{ else }} @@ -10,30 +9,33 @@ {{- range first 6 . }} {{ end -}} {{- else -}} - {{- $images := $.Resources.ByType "image" -}} - {{- $featured := $images.GetMatch "*feature*" -}} - {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} - {{ if and .Params.featureimage (not $featured) }} - {{- $url:= .Params.featureimage -}} - {{ $featured = resources.GetRemote $url }} - {{ end }} - {{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} - {{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} - {{- with $featured -}} - {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} - {{ with . }} -
+ {{ $images := $.Resources.ByType "image" }} + {{ $featuredImage := $images.GetMatch "*feature*" }} + {{ if not $featuredImage }} + {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} {{ end }} - {{ else }} - {{ with .Resize "600x" }} -
+ {{ if and (not $featuredImage) .Params.featureimage }} + {{ $featuredImage = resources.GetRemote .Params.featureimage }} + {{ end }} + {{ if not $featuredImage }} + {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} + {{ end }} + {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} + {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} + {{ $featuredImage = $featuredImage.Resize "600x" }} + {{ end }} + {{ if .Params.hideFeatureImage }} + {{ $featuredImage = false }} + {{ end }} + {{ with $featuredImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} +
+ {{ else }} + {{ with $.Site.Params.images }} + {{ end }} {{ end }} - {{- else -}} - {{- with $.Site.Params.images }} - {{ end -}} - {{- end -}} - {{- end -}} + {{ end }} {{ if and .Draft .Site.Params.article.showDraftLabel }} diff --git a/layouts/partials/article-link/simple.html b/layouts/partials/article-link/simple.html index 5299d663..e56a2afd 100644 --- a/layouts/partials/article-link/simple.html +++ b/layouts/partials/article-link/simple.html @@ -14,8 +14,6 @@ {{ $articleImageClasses = delimit (slice $articleImageClasses "thumbnailshadow md:mr-7") " " }} {{ end }} -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} - {{ $articleInnerClasses := "" }} {{ if .Site.Params.list.showCards }} {{ $articleInnerClasses = delimit (slice $articleInnerClasses "p-4") " " }} @@ -37,30 +35,33 @@ {{- range first 6 . }} {{ end -}} {{- else -}} - {{- $images := $.Resources.ByType "image" -}} - {{- $featured := $images.GetMatch "*feature*" -}} - {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} - {{ if and .Params.featureimage (not $featured) }} - {{- $url:= .Params.featureimage -}} - {{ $featured = resources.GetRemote $url }} - {{ end }} - {{- if not $featured }}{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} - {{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }} - {{- with $featured -}} - {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} - {{ with . }} -
- {{ end }} + {{ $images := $.Resources.ByType "image" }} + {{ $featuredImage := $images.GetMatch "*feature*" }} + {{ if not $featuredImage }} + {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end }} + {{ if and (not $featuredImage) .Params.featureimage }} + {{ $featuredImage = resources.GetRemote .Params.featureimage }} + {{ end }} + {{ if not $featuredImage }} + {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} + {{ end }} + {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} + {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} + {{ $featuredImage = $featuredImage.Resize "600x" }} + {{ end }} + {{ if .Params.hideFeatureImage }} + {{ $featuredImage = false }} + {{ end }} + {{ with $featuredImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} +
{{ else }} - {{ with .Resize "600x" }} -
+ {{ with $.Site.Params.images }} + {{ end }} {{ end }} - {{- else -}} - {{- with $.Site.Params.images }} - {{ end -}} - {{- end -}} - {{- end -}} + {{ end }}
diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 424f8c98..78509d3e 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -45,6 +45,38 @@ {{ if $cssCustom }} {{ $assets.Add "css" (slice $cssCustom) }} {{ end }} + + {{ $images := slice }} + {{ $backgroundAndfeaturedImages := slice }} + {{ range .Site.Pages }} + {{ $images = $images | append (.Page.Resources.ByType "image") }} + {{ if .Params.featureimage }} + {{ $backgroundAndfeaturedImages = $backgroundAndfeaturedImages | append (resources.GetRemote .Params.featureimage) }} + {{ end }} + {{ end }} + {{ $backgroundAndfeaturedImages = $backgroundAndfeaturedImages | append ($images.Match "{*background*,*feature*,*cover*,*thumbnail*}") }} + {{ $siteParams := slice .Site.Params.defaultFeaturedImage .Site.Params.defaultBackgroundImage }} + {{ range $siteParams }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ $backgroundAndfeaturedImages = $backgroundAndfeaturedImages | append (resources.GetRemote .) }} + {{ else }} + {{ $backgroundAndfeaturedImages = $backgroundAndfeaturedImages | append (resources.Get .) }} + {{ end }} + {{ end }} + {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} + {{ range $backgroundAndfeaturedImages }} + {{ $backgroundAndfeaturedImages := . }} + {{ if not (or ($disableImageOptimization) (strings.HasSuffix .Name ".svg")) }} + {{ $backgroundAndfeaturedImages = .Resize "600x" }} + {{ end }} + {{ with $backgroundAndfeaturedImages }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} + {{ $cssBackgroundImage := printf ".%s { background-image: url(\"%s\"); }" $className .RelPermalink }} + {{ $cssBackgroundImage = $cssBackgroundImage | resources.FromString "css/background-image.css" }} + {{ $assets.Add "css" (slice $cssBackgroundImage) }} + {{ end }} + {{ end }} + {{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }}
-{{ end }} - -{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg")}} - {{ with . }} -
- {{ end }} -{{ else }} - {{ with .Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} -
- {{ end }} -{{ end }} - -
+{{ with $backgroundImage }} + {{ if $shouldAddHeaderSpace | default true}} +
+ {{ end }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} +
+
+ class="absolute inset-0 opacity-60 bg-gradient-to-t from-neutral dark:from-neutral-800 to-neutral-100 dark:to-neutral-800 mix-blend-normal">
-
-{{ if $shouldBlur | default false }} -
-{{ $backgroundBlur := resources.Get "js/background-blur.js" }} -{{ $backgroundBlur = $backgroundBlur | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }} - +
+ {{ if $shouldBlur | default false }} +
+ {{ $backgroundBlur := resources.Get "js/background-blur.js" }} + {{ $backgroundBlur = $backgroundBlur | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }} + + {{ end }} {{ end }} -{{- end -}} diff --git a/layouts/partials/hero/basic.html b/layouts/partials/hero/basic.html index 54e84ed3..de8e0882 100644 --- a/layouts/partials/hero/basic.html +++ b/layouts/partials/hero/basic.html @@ -1,37 +1,29 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} - -{{- $images := .Resources.ByType "image" -}} -{{- $featured := $images.GetMatch "*background*" -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "*feature*" }}{{ end -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} - -{{ if and .Params.featureimage (not $featured) }} - {{- $url:= .Params.featureimage -}} - {{ $featured = resources.GetRemote $url }} +{{ $images := .Resources.ByType "image" }} +{{ $backgroundImage := $images.GetMatch "*background*" }} +{{ if not $backgroundImage }} + {{ $backgroundImage := $images.GetMatch "*feature*" }} {{ end }} - -{{- if not $featured }} +{{ if not $backgroundImage }} + {{ $backgroundImage = $images.GetMatch "{*cover*,*thumbnail*}" }} +{{ end }} +{{ if and (not $backgroundImage) .Params.featureimage }} + {{ $backgroundImage = resources.GetRemote .Params.featureimage }} +{{ end }} +{{ if not $backgroundImage }} {{ with .Site.Params.defaultBackgroundImage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ $featured = resources.GetRemote . }} + {{ $backgroundImage = resources.GetRemote . }} {{ else }} - {{ $featured = resources.Get . }} + {{ $backgroundImage = resources.Get . }} {{ end }} {{ end }} -{{ end -}} +{{ end }} +{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} +{{ if and ($backgroundImage) (not (or ($disableImageOptimization) (strings.HasSuffix $backgroundImage.Name ".svg"))) }} + {{ $backgroundImage = $backgroundImage.Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} +{{ end }} -{{- with $featured -}} - {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }} - {{ with . }} -
- {{ end }} - {{ else }} - {{ with .Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} -
- {{ end }} - {{ end }} -{{- end -}} +{{ with $backgroundImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} +
+{{ end }} diff --git a/layouts/partials/hero/thumbAndBackground.html b/layouts/partials/hero/thumbAndBackground.html index 2a8448cb..841f83ec 100644 --- a/layouts/partials/hero/thumbAndBackground.html +++ b/layouts/partials/hero/thumbAndBackground.html @@ -1,98 +1,77 @@ -{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} - -{{- $images := .Resources.ByType "image" -}} -{{- $background := $images.GetMatch "*background*" -}} - -{{- if not $background }} +{{ $images := .Resources.ByType "image" }} +{{ $backgroundImage := $images.GetMatch "*background*" }} +{{ if not $backgroundImage }} {{ with .Site.Params.defaultBackgroundImage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ $background = resources.GetRemote . }} + {{ $backgroundImage = resources.GetRemote . }} {{ else }} - {{ $background = resources.Get . }} + {{ $backgroundImage = resources.Get . }} {{ end }} {{ end }} -{{ end -}} - -{{- if not $background }}{{ $background = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{- if not $background }}{{ $background = $images.GetMatch "*feature*" }}{{ end -}} -{{- $featured := $images.GetMatch "*feature*" -}} -{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} -{{ if .Params.featureimage }} - {{- $url:= .Params.featureimage -}} - {{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}} {{ end }} -{{- if not $featured }}{{ $featured = $images.GetMatch "*background*" }}{{ end -}} +{{ if not $backgroundImage }} + {{ $backgroundImage = $images.GetMatch "{*cover*,*thumbnail*}" }} +{{ end }} +{{ if not $backgroundImage }} + {{ $backgroundImage := $images.GetMatch "*feature*" }} +{{ end }} +{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} +{{ if and ($backgroundImage) (not (or ($disableImageOptimization) (strings.HasSuffix $backgroundImage.Name ".svg"))) }} + {{ $backgroundImage = $backgroundImage.Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} +{{ end }} -{{- if not $featured }} +{{ $featuredImage := $images.GetMatch "*feature*" }} +{{ if not $featuredImage }} + {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} +{{ end }} +{{ if and (not $featuredImage) .Params.featureimage }} + {{ $featuredImage = resources.GetRemote .Params.featureimage }} +{{ end }} +{{ if not $featuredImage }} + {{ $featuredImage = resources.Get .Site.Params.defaultFeaturedImage }} +{{ end }} +{{ if not $featuredImage }} + {{ $featuredImage := $images.GetMatch "*background*" }} +{{ end }} +{{ if not $featuredImage }} {{ with .Site.Params.defaultFeaturedImage }} {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} - {{ $featured = resources.GetRemote . }} + {{ $featuredImage = resources.GetRemote . }} {{ else }} - {{ $featured = resources.Get . }} + {{ $featuredImage = resources.Get . }} {{ end }} {{ end }} -{{ end -}} +{{ end }} +{{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} + {{ $featuredImage = $featuredImage.Resize "600x" }} +{{ end }} -{{ $isParentList := eq (.Scratch.Get "scope") "list" }} +{{ $isParentList := eq (.Scratch.Get "scope") "list" }} {{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or - (and ($.Site.Params.article.layoutBackgroundBlur | default true) (not $isParentList)) - (and ($.Site.Params.list.layoutBackgroundBlur | default true) ($isParentList)) - ) -}} + (and ($.Site.Params.article.layoutBackgroundBlur | default true) (not $isParentList)) + (and ($.Site.Params.list.layoutBackgroundBlur | default true) ($isParentList)) + ) }} -{{- with $featured -}} - {{ if or $disableImageOptimization (strings.HasSuffix . ".svg") }} - {{ with . }} -
- {{ end }} - {{ else }} - {{ with .Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} -
- {{ end }} - {{ end }} -{{- end -}} +{{ with $featuredImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} +
+{{ end }} -{{- with $background -}} - - {{ if or $disableImageOptimization (strings.HasSuffix . ".svg") }} - {{ with . }} -
-
-
-
- {{ end }} - {{ else }} - {{ with .Resize (print ($.Site.Params.backgroundImageWidth | default "1200") "x") }} -
-
-
-
- {{ end }} - {{ end }} - -{{- end -}} +{{ with $backgroundImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} +
+
+
+
+
+
+{{ end }} {{ if $shouldBlur | default false }} -
+
{{ $backgroundBlur := resources.Get "js/background-blur.js" }} - {{ $backgroundBlur = $backgroundBlur | resources.Minify | resources.Fingerprint (.Site.Params.fingerprintAlgorithm | default "sha512") }} - + {{ $backgroundBlur = $backgroundBlur | resources.Minify | resources.Fingerprint ($.Site.Params.fingerprintAlgorithm | default "sha512") }} + {{ end }} diff --git a/layouts/partials/term-link/card.html b/layouts/partials/term-link/card.html index 280a74d4..31fdc225 100644 --- a/layouts/partials/term-link/card.html +++ b/layouts/partials/term-link/card.html @@ -1,32 +1,29 @@
- {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} - {{- with site.Params.images -}} {{- range first 6 . }} {{ end -}} {{- else -}} - {{- $images := .Page.Resources.ByType "image" -}} - {{- $featured := $images.GetMatch "*feature*" -}} - {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} - {{- with $featured -}} - {{ if $disableImageOptimization }} - {{ with . }} -
- {{ end }} - {{ else }} - {{ with .Resize "600x" }} -
- {{ end }} + {{ $images := .Page.Resources.ByType "image" }} + {{ $featuredImage := $images.GetMatch "*feature*" }} + {{ if not $featuredImage }} + {{ $featuredImage = $images.GetMatch "{*cover*,*thumbnail*}" }} + {{ end }} + {{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }} + {{ if and ($featuredImage) (not (or ($disableImageOptimization) (strings.HasSuffix $featuredImage.Name ".svg"))) }} + {{ $featuredImage = $featuredImage.Resize "600x" }} + {{ end }} + {{ with $featuredImage }} + {{ $className := printf "background-image-%s" (md5 .RelPermalink) }} + + {{ else }} + {{ with site.Params.images }} + {{ end }} - {{- else -}} - {{- with site.Params.images }} - - {{ end -}} - {{- end -}} - {{- end -}} + {{ end }} + {{ end }} {{ if site.Params.taxonomy.showTermCount | default true }}