refactor: use helper/image in links.html (#1290)

* refactor: use `helper/image` in `links.html`

* fix: check for $image existence before accessing
This commit is contained in:
Jimmy
2026-03-05 13:51:34 +01:00
committed by GitHub
parent 12f05571cf
commit a95d0e7c85
@@ -15,13 +15,16 @@
</footer> </footer>
</div> </div>
{{ with $link.image }} {{- $image := partial "helper/image" (dict "Image" $link.image "Resources" $.Resources) -}}
{{ $permalink := . }} {{- with $image -}}
{{ with ($.Resources.GetMatch (printf "%s" (. | safeURL))) }}
{{ $permalink = .RelPermalink }}
{{ end }}
<div class="article-image"> <div class="article-image">
<img src="{{ $permalink }}" loading="lazy"{{ with $link.alt }} alt="{{ . }}"{{ end }}> <img
src="{{ .Permalink }}"
loading="lazy"
{{ with $link.alt }} alt="{{ . }}"{{ end }}
{{ with .Width }} width="{{ . }}"{{ end }}
{{ with .Height }} height="{{ . }}"{{ end }}
>
</div> </div>
{{ end }} {{ end }}
</a> </a>