forked from AmazingRise/hugo-theme-diary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
figure.html
31 lines (31 loc) · 971 Bytes
/
figure.html
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
31
{{- $alt := .Get "alt" | default "image" -}}
{{- $width := .Get "w" | default "100%" -}}
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
{{- /* Begin a tag */ -}}
{{- if .Get "link" -}}
<a href="{{ .Get "link" }}"
{{ with .Get "target" }} target="{{ . }}"{{ end }}
{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
{{- end -}}
{{- /* Begin img tag */ -}}
{{- if .Get "src" -}}
<img src="{{ .Get "src" }}"
{{- else -}}
<img src="/{{ .Get "folder" | default "post-img" }}/{{ .Get "name" }}"
{{- end -}}
loading="lazy"
alt="{{ $alt | markdownify| plainify }}"
style='max-width: {{ $width }}; {{ with .Get "h" }}max-height: {{ . }};{{ end }}'
/>{{- /* Close img tag */ -}}
{{- if .Get "link" -}}</a>{{- end -}}
{{- /* Close a tag */ -}}
{{- if .Get "title" -}}
<figcaption>
<p>
{{- with .Get "attrlink" }}<a href="{{ . }}">{{- end -}}
{{- .Get "title" | markdownify -}}
{{- if .Get "attrlink" }}</a>{{ end }}
</p>
</figcaption>
{{- end -}}
</figure>