Skip to content

Commit

Permalink
Custom figure shortcode to support captions
Browse files Browse the repository at this point in the history
  • Loading branch information
chollinger93 committed Sep 3, 2021
1 parent b7cb50a commit 4847f3f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions layouts/shortcodes/figure.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!-- image -->
<figure {{ with .Get "class" }}class="{{.}}"{{ end }}>
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }} />
{{ if .Get "link" }}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr") }}
<figcaption>{{ if isset .Params "title" }}
{{ .Get "title" }}{{ end }}
{{ if or (.Get "caption") (.Get "attr") }}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink" }}<a href="{{ . }}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink" }}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure>
<!-- image -->

0 comments on commit 4847f3f

Please sign in to comment.