🐛 Fix: make thumbAndBackground behavior consistent

Add support for URL input, matching the behavior of other hero partials.
This commit is contained in:
ZhenShuo Leo
2025-05-03 16:46:10 +08:00
parent 1d21656d5e
commit f19c61cb97

View File

@@ -2,7 +2,17 @@
{{- $images := .Resources.ByType "image" -}} {{- $images := .Resources.ByType "image" -}}
{{- $background := $images.GetMatch "*background*" -}} {{- $background := $images.GetMatch "*background*" -}}
{{- if not $background }}{{ with .Site.Params.defaultBackgroundImage }}{{ $background = resources.Get . }}{{ end }}{{ end -}}
{{- if not $background }}
{{ with .Site.Params.defaultBackgroundImage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $background = resources.GetRemote . }}
{{ else }}
{{ $background = resources.Get . }}
{{ end }}
{{ end }}
{{ end -}}
{{- if not $background }}{{ $background = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{- if not $background }}{{ $background = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
{{- if not $background }}{{ $background = $images.GetMatch "*feature*" }}{{ end -}} {{- if not $background }}{{ $background = $images.GetMatch "*feature*" }}{{ end -}}
{{- $featured := $images.GetMatch "*feature*" -}} {{- $featured := $images.GetMatch "*feature*" -}}
@@ -12,7 +22,17 @@
{{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}} {{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}}
{{ end }} {{ end }}
{{- if not $featured }}{{ $featured = $images.GetMatch "*background*" }}{{ end -}} {{- if not $featured }}{{ $featured = $images.GetMatch "*background*" }}{{ end -}}
{{- if not $featured }}{{ with .Site.Params.defaultBackgroundImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}}
{{- if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }}
{{ else }}
{{ $featured = resources.Get . }}
{{ end }}
{{ end }}
{{ end -}}
{{ $isParentList := eq (.Scratch.Get "scope") "list" }} {{ $isParentList := eq (.Scratch.Get "scope") "list" }}
{{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or {{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or
(and ($.Site.Params.article.layoutBackgroundBlur | default true) (not $isParentList)) (and ($.Site.Params.article.layoutBackgroundBlur | default true) (not $isParentList))