feat(article-link): support internal links for featureimage

This commit also gives the `featureimage` frontmatter the highest priority, preventing it from being overridden by hidden logic.
This commit is contained in:
ZhenShuo Leo
2025-08-31 17:41:48 +08:00
parent 6d6b5d3946
commit 9c1d56e0e7
4 changed files with 61 additions and 33 deletions

View File

@@ -34,18 +34,25 @@
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ if not .Params.hideFeatureImage }}
{{ $images := $target.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if and $target.Params.featureimage (not $featured) }}
{{ $url:= $target.Params.featureimage }}
{{ $featured = resources.GetRemote $url }}
{{ if not $target.Params.hideFeatureImage }}
{{ with $target.Params.featureimage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }}
{{ else }}
{{ $featured = resources.Get . }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ $images := $target.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if not $featured }}
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end }}
{{ end }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}

View File

@@ -5,17 +5,24 @@
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if and .Params.featureimage (not $featured) }}
{{ $url:= .Params.featureimage }}
{{ $featured = resources.GetRemote $url }}
{{ with .Params.featureimage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }}
{{ else }}
{{ $featured = resources.Get . }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if not $featured }}
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end }}
{{ end }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}

View File

@@ -8,17 +8,24 @@
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ if not .Params.hideFeatureImage }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if and .Params.featureimage (not $featured) }}
{{ $url:= .Params.featureimage }}
{{ $featured = resources.GetRemote $url }}
{{ with .Params.featureimage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }}
{{ else }}
{{ $featured = resources.Get . }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end }}
{{ end }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}

View File

@@ -35,17 +35,24 @@
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ if not .Params.hideFeatureImage }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if and .Params.featureimage (not $featured) }}
{{ $url:= .Params.featureimage }}
{{ $featured = resources.GetRemote $url }}
{{ with .Params.featureimage }}
{{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }}
{{ $featured = resources.GetRemote . }}
{{ else }}
{{ $featured = resources.Get . }}
{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end }}
{{ end }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}