aboutsummaryrefslogtreecommitdiffstats
path: root/layouts/partials/leading_image.html
blob: 2f8e4913427229cc0cd3449a0e6dc17526e9985e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
{{ $image := "" }}
{{ if (.Resources.ByType "image").GetMatch "*featured*" }}
  {{ $image =  (.Resources.ByType "image").GetMatch "*featured*" }}
{{ else if resources.Get (index .Params.images 0) }}
  {{ $image =  resources.Get (index .Params.images 0) }}
{{ end }}
{{ with $image }}
  <div class="text-center">
    <div class="relative inline-block">
      <img
        src="{{ if ne .MediaType.SubType "svg" }}
          {{ $image := .Fit (default "768x400" $.Params.image_size) }}
          {{ $image.RelPermalink }}
        {{ else }}
          {{ $image.RelPermalink }}
        {{ end }}"
        class="m-0"
        alt="{{ .Title }}"
      />
      {{ with $.Params.caption }}
        <a
          href="{{ .url }}"
          class="text-white block absolute bottom-0 right-0 p-2 bg-black bg-opacity-40 rounded"
        >
          {{ .text }}
        </a>
      {{ end }}
    </div>
  </div>
{{ end }}