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 }} {{ $alt := .alt }}
{{ $noscriptSupport := .noscript }} {{ $noscriptSupport := .noscript }}
{{ $imgDict := .imgDict }} {{ $imgDict := .imgDict }}
{{ if $noscriptSupport }} {{- if $noscriptSupport -}}
<noscript> <noscript>
<!-- TODO: add responsiveness --> {{ partial "renderer/native" . }}
<img src="{{ $imgDict.default.Permalink }}" {{ with $alt }} alt="{{ . }}" {{ end -}} </noscript>
class="{{ $class }}" loading="lazy" {{- end -}}
{{- with $imgDict.default }} height="{{ .Height }}" width="{{ .Width }}" {{ end -}}>
</noscript>
{{ end }}
<img <img
{{- with $imgDict.lqip -}} {{- with $imgDict.lqip -}}
{{- $placeholderB64 := .Content | base64Encode -}} {{- $placeholderB64 := .Content | base64Encode -}}
@@ -24,5 +21,5 @@
src="{{ $imgDict.default.Permalink }}" class="{{ $class }} lazyload" src="{{ $imgDict.default.Permalink }}" class="{{ $class }} lazyload"
{{- end -}} {{- end -}}
{{- with (default $imgDict.default $imgDict.lqip) }} height="{{ .Height }}" width="{{ .Width }}" {{- 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 }}> {{- 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 }}>