refactor(partials): extract to native renderer

This commit is contained in:
kdevo
2021-10-09 16:04:49 +02:00
parent 621d0bc7c6
commit 8121a2f2e1
2 changed files with 15 additions and 9 deletions
+6 -9
View File
@@ -2,14 +2,11 @@
{{ $alt := .alt }}
{{ $noscriptSupport := .noscript }}
{{ $imgDict := .imgDict }}
{{ if $noscriptSupport }}
<noscript>
<!-- TODO: add responsiveness -->
<img src="{{ $imgDict.default.Permalink }}" {{ with $alt }} alt="{{ . }}" {{ end -}}
class="{{ $class }}" loading="lazy"
{{- with $imgDict.default }} height="{{ .Height }}" width="{{ .Width }}" {{ end -}}>
</noscript>
{{ end }}
{{- if $noscriptSupport -}}
<noscript>
{{ partial "renderer/native" . }}
</noscript>
{{- end -}}
<img
{{- with $imgDict.lqip -}}
{{- $placeholderB64 := .Content | base64Encode -}}
@@ -24,5 +21,5 @@
src="{{ $imgDict.default.Permalink }}" class="{{ $class }} lazyload"
{{- end -}}
{{- with (default $imgDict.default $imgDict.lqip) }} height="{{ .Height }}" width="{{ .Width }}" {{- end -}}
{{- if $imgDict.responsive -}}{{ with partial "renderer/_srcset" $imgDict }} data-sizes="auto" data-srcset="{{ . }}" {{- end }}{{- end -}}
{{- if $imgDict.responsive -}}{{ with partial "renderer/_srcset" $imgDict }} data-sizes="auto" data-srcset="{{ . }}"{{- end }} {{- end -}}
{{- with $alt }} alt="{{ . }}" {{- end }}>
+9
View File
@@ -0,0 +1,9 @@
{{ $class := .class }}
{{ $alt := .alt }}
{{ $imgDict := .imgDict }}
<img src="{{ $imgDict.default.Permalink }}"
class="{{ $class }}" loading="lazy"
{{- with $imgDict.default }} height="{{ .Height }}" width="{{ .Width }}" {{- end -}}
{{- if $imgDict.responsive -}} {{ with partial "renderer/_srcset" $imgDict }} srcset="{{ . }}"{{- end }} {{- end -}}
{{- with $alt }} alt="{{ . }}" {{- end }}>