hugo-theme-hyde-hyde/layouts/shortcodes/fig.html

44 lines
1.6 KiB
HTML
Raw Normal View History

{{ if .Get "caption" }}
{{ $.Scratch.Set "caption" (.Get "caption") }}
{{ else if .Get "alt" }}
{{ $.Scratch.Set "caption" (.Get "alt") }}
{{ end }}
2018-07-27 23:06:12 +00:00
<!-- resolve absolute image path -->
{{ $permalink := $.Page.Permalink }}
{{ $image := .Get "src" }}
{{ $image_link_absolute := (findRE "^/" $image) }}
2018-07-21 07:08:41 +00:00
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
2018-07-27 23:06:12 +00:00
{{ if .Get "link"}}
<a href="{{ .Get "link" }}"
{{ with .Get "target" }} target="{{ . }}"{{ end }}
{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{ end }}
<img
{{ if $image_link_absolute }}
src="{{ $image | absURL }}"
{{ else }}
src="{{ (printf "%s%s" $permalink $image) }}"
{{ end }}
{{ if .Get "alt" }}alt="{{ .Get "alt" | markdownify | plainify }}"
{{ else if .Get "caption" }}alt="{{ .Get "caption" | markdownify | plainify }}"
{{ end }}
{{ with .Get "align" }}align="{{ . }}"{{ end }}
2018-07-29 23:23:19 +00:00
{{ with .Get "height" }}width="{{ . }}"{{ end }}
{{ with .Get "width" }}width="{{ . }}"{{ end }} style="max-width: 100%;"
/>
2018-07-27 23:06:12 +00:00
{{ if .Get "link"}}</a>{{ end }}
<!-- caption and attr-->
{{ if ($.Scratch.Get "caption") }}
2018-07-21 07:08:41 +00:00
<figcaption>
2018-07-27 23:06:12 +00:00
<span class="img--caption">
Figure {{ $.Page.Scratch.Get "fig" }}. {{ $.Scratch.Get "caption" | markdownify | plainify }}
2018-07-27 23:06:12 +00:00
{{ if .Get "attr" }}
2018-07-29 22:17:05 +00:00
[{{- with .Get "attrlink"}}<a href="{{ . }}">{{ end }}{{ .Get "attr" | markdownify }}{{ if .Get "attrlink"}}</a>{{ end -}}]
2018-07-27 23:06:12 +00:00
{{ end }}
</span>
2018-07-21 07:08:41 +00:00
</figcaption>
{{ end }}
2018-07-21 07:08:41 +00:00
</figure>
{{ .Page.Scratch.Add "fig" 1 }}
{{ $.Scratch.Delete "caption"}}