fix(article-link): skip fetching images when hideFeatureImage is true

This commit is contained in:
ZhenShuo Leo
2025-08-31 17:20:42 +08:00
parent ff3a6b4253
commit 6d6b5d3946
4 changed files with 53 additions and 50 deletions

View File

@@ -32,9 +32,10 @@
{{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }}
{{ end }}
{{ $images := $target.Resources.ByType "image" }}
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ if not .Params.hideFeatureImage }}
{{ $images := $target.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
@@ -45,13 +46,13 @@
{{ if not $featured }}
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end }}
{{ if $target.Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ $featuredURL = (.Resize "600x").RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
<div class="{{ $articleClasses }}">

View File

@@ -3,9 +3,9 @@
*/}}
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ $images := $.Resources.ByType "image" }}
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
@@ -14,7 +14,7 @@
{{ $featured = resources.GetRemote $url }}
{{ end }}
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}

View File

@@ -5,9 +5,10 @@
*/}}
{{ $disableImageOptimization := .Page.Site.Params.disableImageOptimization | default false }}
{{ $images := $.Resources.ByType "image" }}
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ if not .Params.hideFeatureImage }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
@@ -18,13 +19,13 @@
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end }}
{{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ $featuredURL = (.Resize "600x").RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
<div

View File

@@ -32,9 +32,10 @@
{{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }}
{{ end }}
{{ $images := $.Resources.ByType "image" }}
{{ $featured := "" }}
{{ $featuredURL := "" }}
{{ if not .Params.hideFeatureImage }}
{{ $images := $.Resources.ByType "image" }}
{{ range slice "*feature*" "*cover*" "*thumbnail*" }}
{{ if not $featured }}{{ $featured = $images.GetMatch . }}{{ end }}
{{ end }}
@@ -45,13 +46,13 @@
{{ if not $featured }}
{{ with .Site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
{{ end }}
{{ if .Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
{{ with $featured }}
{{ $featuredURL = .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ $featuredURL = (.Resize "600x").RelPermalink }}
{{ end }}
{{ end }}
{{ end }}
<div class="{{ $articleClasses }}">