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:
@@ -14,14 +14,17 @@
|
||||
{{ end }}
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
{{ with $link.image }}
|
||||
{{ $permalink := . }}
|
||||
{{ with ($.Resources.GetMatch (printf "%s" (. | safeURL))) }}
|
||||
{{ $permalink = .RelPermalink }}
|
||||
{{ end }}
|
||||
|
||||
{{- $image := partial "helper/image" (dict "Image" $link.image "Resources" $.Resources) -}}
|
||||
{{- with $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>
|
||||
{{ end }}
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user