Browse Source

use resource based featured image

master
Alexander Avery 9 months ago
parent
commit
229492e397
  1. 2
      layouts/partials/article-card.html
  2. 2
      layouts/partials/article-meta.html
  3. 7
      layouts/partials/image.html

2
layouts/partials/article-card.html

@ -1,7 +1,7 @@
<article class="shadow float-on-hover card"> <article class="shadow float-on-hover card">
<div class="article-image"> <div class="article-image">
<a href=" {{ .Permalink }}"> <a href=" {{ .Permalink }}">
{{ $image := .Resources.GetMatch .Params.featured.url }} {{ $image := .Resources.GetMatch "featured" }}
{{ partial "image.html" (dict "image" $image "alt" .Params.featured.alt "class" "fill-wh")}} {{ partial "image.html" (dict "image" $image "alt" .Params.featured.alt "class" "fill-wh")}}
</a> </a>
</div> </div>

2
layouts/partials/article-meta.html

@ -16,7 +16,7 @@
<a class="small-text" href="{{ .Permalink }}">{{ .LinkTitle }}</a> <a class="small-text" href="{{ .Permalink }}">{{ .LinkTitle }}</a>
{{ end }} {{ end }}
{{ $image := (.Resources.GetMatch .Params.featured.url) }} {{ $image := (.Resources.GetMatch "featured") }}
{{ partial "image.html" (dict "image" $image "alt" .Params.featured.alt "class" "shadow featured") }} {{ partial "image.html" (dict "image" $image "alt" .Params.featured.alt "class" "shadow featured") }}
</section> </section>

7
layouts/partials/image.html

@ -1,5 +1,5 @@
<img class="{{ .class }}" <img class="{{ .class }}"
{{ with .image }} {{- with .image -}}
srcset=" srcset="
{{- with (.Resize "600x q40") -}} {{- with (.Resize "600x q40") -}}
{{ printf "%s %dw," .RelPermalink .Width }} {{ printf "%s %dw," .RelPermalink .Width }}
@ -15,6 +15,7 @@
{{- with (.Resize "600x q40") -}} {{- with (.Resize "600x q40") -}}
{{ .RelPermalink }} {{ .RelPermalink }}
{{- end -}}" {{- end -}}"
{{ end }}
alt="{{ .alt }}" alt="{{ .Params.alt }}"
{{- end -}}
> >

Loading…
Cancel
Save