Inline image template
This is for embedding SVGs inline.
This commit is contained in:
parent
05956b83b8
commit
7d56bd2f78
1 changed files with 24 additions and 0 deletions
24
layouts/partials/page/figures/inline-image.html
Normal file
24
layouts/partials/page/figures/inline-image.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{{- $image := .page.Resources.GetMatch .name -}}
|
||||
|
||||
{{ if not $image }}
|
||||
{{ errorf "No images named '%s' found. %s " .name .page.Permalink }}
|
||||
{{ end }}
|
||||
|
||||
{{ if ne $image.MediaType.SubType "svg" }}
|
||||
{{ errorf "Only SVGs may be inlined. %s" $image.Permalink }}
|
||||
{{ end }}
|
||||
|
||||
{{- $classes := slice "figure" "figure--image" "figure--inline-image" -}}
|
||||
{{- if eq .size "main" -}}
|
||||
{{ $classes = $classes | append "figure--main-column" }}
|
||||
{{- end -}}
|
||||
{{- with .class -}}
|
||||
{{ $classes = $classes | append . }}
|
||||
{{- end -}}
|
||||
|
||||
<figure class="{{ delimit $classes " " }}">
|
||||
{{ $image.Content | safeHTML }}
|
||||
{{ if .shouldShowTitle }}
|
||||
{{ partial "page/figures/caption.html" (merge . (dict "resource" $image)) }}
|
||||
{{ end }}
|
||||
</figure>
|
Loading…
Add table
Add a link
Reference in a new issue