hugo-tufte/layouts/shortcodes/figure.html
2023-04-15 01:53:05 +01:00

51 lines
1.5 KiB
HTML

{{ $type := .Get "type" | default "normal" }}
<!-- begin figure tag -->
{{ if not (eq $type "margin") }}
{{ if eq $type "full" }}
<figure class="fullwidth">
{{ else }}
<figure {{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{ end }}
{{ end }}
<!-- begin inner elements -->
{{ if eq $type "full" }}
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
<img src="{{ .Get "src" }}" {{ with .Get "alt"}}alt="{{ . }}"{{ end }}>
{{ if .Get "link" }}</a>{{ end }}
<figcaption>
{{ else }}{{/* margin or normal */}}
<label for="{{ .Get "label" }}" class="margin-toggle">&#128172;</label>
<input type="checkbox" id="{{ .Get "label" }}" class="margin-toggle">
<span class="marginnote">
{{ if eq $type "margin" }}
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
<img src="{{ .Get "src" }}" {{ with .Get "alt"}}alt="{{ . }}"{{ end }}>
{{ if .Get "link" }}</a>{{ end }}
{{ end }}
{{ end }}
{{ with .Get "title"}}<strong>{{ . }} </strong>{{ end}}
{{ with .Get "caption"}}{{ . }}{{ end }}
{{ with .Get "attrlink"}}<a href="{{ .}}">{{ end }}
{{ with .Get "attr" }}{{ . }}{{ end }}
{{ if .Get "attrlink" }}</a>{{ end }}
<!-- end inner elements -->
{{ if eq $type "full" }}
</figcaption>
{{ else }}
</span>
{{ end }}
{{ if ( eq $type "normal" ) }}
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
<img src="{{ .Get "src" }}" {{ with .Get "alt"}}alt="{{ . }}"{{ end }}>
{{ if .Get "link" }}</a>{{ end }}
{{ end }}
<!-- end figure tag -->
{{ if not (eq $type "margin") }}
</figure>
{{ end }}