refactor(article-link): unify featured image rendering with MediaType check

This commit is contained in:
ZhenShuo Leo
2025-08-31 16:47:21 +08:00
parent e3194eca1e
commit c8ee5fc657
4 changed files with 16 additions and 40 deletions

View File

@@ -48,18 +48,12 @@
{{ end }}
{{ if $target.Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
{{ with $featured }}
{{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }}
{{ with . }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }}
{{ else }}
{{ with .Resize "600x" }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ .RelPermalink }});"></div>
{{ end }}
{{ $featuredURL := .RelPermalink }}
{{ if not (or $disableImageOptimization (eq .MediaType.SubType "svg")) }}
{{ $featuredURL = (.Resize "600x").RelPermalink }}
{{ end }}
<div class="{{ $articleImageClasses }}" style="background-image:url({{ $featuredURL }});"></div>
{{ end }}
<div class="{{ $articleInnerClasses }}">
<div class="items-center text-start text-xl font-semibold">
{{ with $target.Params.externalUrl }}