New absfigure shortcode
This commit is contained in:
parent
f0643ea038
commit
7f9bae2d9d
@ -115,6 +115,8 @@ already implemented:
|
||||
- Reply by email: if you supply an email address, the theme creates a "Reply to
|
||||
this post by email" button at the end of every post (see Kev Quirk's [original
|
||||
implementation](https://kevquirk.com/adding-the-post-title-to-my-reply-by-email-button)).
|
||||
- `absfigure` shortcode: a shortcut to use the `figure` shortcode that also
|
||||
converts relative URLs into absolute URLs by using the `absURL` function.
|
||||
- Single-use CSS (EXPERIMENTAL): you can add some styles to a single page by
|
||||
writing the CSS you need in `assets/{custom_css}.css` and then including
|
||||
`style: "{custom_css}.css"` in the [front
|
||||
|
29
layouts/shortcodes/absfigure.html
Normal file
29
layouts/shortcodes/absfigure.html
Normal file
@ -0,0 +1,29 @@
|
||||
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
|
||||
{{- if .Get "link" -}}
|
||||
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>
|
||||
{{- end -}}
|
||||
<img src="{{ .Get "src" | absURL}}"
|
||||
{{- if or (.Get "alt") (.Get "caption") }}
|
||||
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify| plainify }}{{ end }}"
|
||||
{{- end -}}
|
||||
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
|
||||
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
|
||||
{{- with .Get "loading" }} loading="{{ . }}"{{ end -}}
|
||||
/><!-- Closing img tag -->
|
||||
{{- if .Get "link" }}</a>{{ end -}}
|
||||
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr") -}}
|
||||
<figcaption>
|
||||
{{ with (.Get "title") -}}
|
||||
<h4>{{ . }}</h4>
|
||||
{{- end -}}
|
||||
{{- if or (.Get "caption") (.Get "attr") -}}<p>
|
||||
{{- .Get "caption" | markdownify -}}
|
||||
{{- with .Get "attrlink" }}
|
||||
<a href="{{ . }}">
|
||||
{{- end -}}
|
||||
{{- .Get "attr" | markdownify -}}
|
||||
{{- if .Get "attrlink" }}</a>{{ end }}</p>
|
||||
{{- end }}
|
||||
</figcaption>
|
||||
{{- end }}
|
||||
</figure>
|
Loading…
x
Reference in New Issue
Block a user