header.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <header class="article-header">
  2. {{- $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink "article" -}}
  3. {{ if $image.exists }}
  4. <div class="article-image">
  5. <a href="{{ .RelPermalink }}">
  6. {{ if $image.resource }}
  7. {{- $Permalink := $image.resource.RelPermalink -}}
  8. {{- $Width := $image.resource.Width -}}
  9. {{- $Height := $image.resource.Height -}}
  10. {{- $Srcset := "" -}}
  11. {{- if (default true .Page.Site.Params.imageProcessing.cover.enabled) -}}
  12. {{- $thumbnail := $image.resource.Resize "800x" -}}
  13. {{- $thumbnailRetina := $image.resource.Resize "1600x" -}}
  14. {{- $Srcset = printf "%s 800w, %s 1600w" $thumbnail.RelPermalink $thumbnailRetina.RelPermalink -}}
  15. {{- $Permalink = $thumbnail.RelPermalink -}}
  16. {{- $Width = $thumbnail.Width -}}
  17. {{- $Height = $thumbnail.Height -}}
  18. {{- end -}}
  19. <img src="{{ $Permalink }}"
  20. {{ with $Srcset }}srcset="{{ . }}"{{ end }}
  21. width="{{ $Width }}"
  22. height="{{ $Height }}"
  23. loading="lazy"
  24. alt="Featured image of post {{ .Title }}" />
  25. {{ else }}
  26. <img src="{{ $image.permalink }}" loading="lazy" alt="Featured image of post {{ .Title }}" />
  27. {{ end }}
  28. </a>
  29. </div>
  30. {{ end }}
  31. {{ partialCached "article/components/details" . .RelPermalink }}
  32. </header>