SEOOptimierungenAlex07092025
This commit is contained in:
parent
6828c3f835
commit
b7f8f2ac5e
34 changed files with 4426 additions and 253 deletions
26
layouts/partials/img.html
Normal file
26
layouts/partials/img.html
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{{/* Re-usable image partial with alt + size fallback
|
||||
Usage:
|
||||
{{ partial "img.html" (dict "src" "/images/foo.webp" "alt" "Kurzbeschreibung" "class" "img-fluid" "loading" "lazy" "page" .) }}
|
||||
*/}}
|
||||
{{- $src := .src -}}
|
||||
{{- $alt := .alt | default .page.Title -}}
|
||||
{{- $class := .class -}}
|
||||
{{- $loading := .loading | default "lazy" -}}
|
||||
|
||||
{{- $w := 0 -}}
|
||||
{{- $h := 0 -}}
|
||||
{{- $static := printf "static/%s" (strings.TrimLeft "/" $src) -}}
|
||||
{{- if fileExists $static -}}
|
||||
{{- with (imageConfig $static) -}}
|
||||
{{- $w = .Width -}}
|
||||
{{- $h = .Height -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
<img src="{{ $src | relURL }}"
|
||||
alt="{{ $alt | plainify }}"
|
||||
loading="{{ $loading }}"
|
||||
decoding="async"
|
||||
{{ if gt $w 0 }}width="{{ $w }}"{{ end }}
|
||||
{{ if gt $h 0 }}height="{{ $h }}"{{ end }}
|
||||
class="{{ $class }}">
|
||||
Loading…
Add table
Add a link
Reference in a new issue