kern

White space theme for Hugo
Log | Files | Refs | LICENSE

figure.html (2092B)


      1 <figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
      2   {{- if .Get "link" -}}
      3     <a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
      4   {{- end -}}
      5 
      6   {{- $u := urls.Parse (.Get "src") -}}
      7   {{- $src := .Get "src" -}}
      8   {{- if not $u.IsAbs -}}
      9     {{- with or (.Page.Resources.Get $u.Path) (resources.Get $u.Path) -}}
     10       {{- $src = .RelPermalink -}}
     11     {{- end -}}
     12   {{- end -}}
     13   
     14   {{ $ext := lower (path.Ext $src) }}
     15   {{ if or (eq $ext ".png") (eq $ext ".jpg") (eq $ext ".jpeg") (eq $ext ".gif") (eq $ext ".webp") }}
     16     <img src="{{ $src }}"
     17       {{- if or (.Get "alt") (.Get "caption") }}
     18       alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
     19       {{- end -}}
     20       {{- with .Get "width" }} width="{{ . }}"{{ end -}}
     21       {{- with .Get "height" }} height="{{ . }}"{{ end -}}
     22       {{- with .Get "loading" }} loading="{{ . }}"{{ end -}}
     23       {{- with .Get "id" }} id="{{ . }}"{{ end -}}
     24     >
     25   {{ else if or (eq $ext ".mp4") }}
     26     <video src="{{ $src }}"
     27       {{- if or (.Get "alt") (.Get "caption") }}
     28       alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
     29       {{- end -}}
     30       {{- with .Get "width" }} width="{{ . }}"{{ end -}}
     31       {{- with .Get "height" }} height="{{ . }}"{{ end -}}
     32       {{- with .Get "loading" }} loading="{{ . }}"{{ end -}}
     33       {{- with .Get "id" }} id="{{ . }}"{{ end -}}
     34       controls
     35       playsinline muted
     36     ></video>
     37   {{ end }}
     38   {{- if .Get "link" }}</a>{{ end -}}
     39   {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
     40     <figcaption>
     41       {{ with (.Get "title") -}}
     42         <h4>{{ . }}</h4>
     43       {{- end -}}
     44       {{- if or (.Get "caption") (.Get "attr") -}}<p>
     45         {{- .Get "caption" | markdownify -}}
     46         {{- with .Get "attrlink" }}
     47           <a href="{{ . }}">
     48         {{- end -}}
     49         {{- .Get "attr" | markdownify -}}
     50         {{- if .Get "attrlink" }}</a>{{ end }}</p>
     51       {{- end }}
     52     </figcaption>
     53   {{- end }}
     54 </figure>