Add shortcode for embedding resources in content
This commit is contained in:
parent
ddc1f4d484
commit
8fa063174e
1 changed files with 28 additions and 0 deletions
28
layouts/shortcodes/resource.html
Normal file
28
layouts/shortcodes/resource.html
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{{ $original := .Page.Resources.GetByPrefix (.Get "src") }}
|
||||||
|
{{ $options := .Get "options" }}
|
||||||
|
|
||||||
|
{{ .Scratch.Set "image" $original }}
|
||||||
|
|
||||||
|
{{ if $options }}
|
||||||
|
{{ $command := (default "Resize" (.Get "command")) }}
|
||||||
|
{{ if eq $command "Fit"}}
|
||||||
|
{{ .Scratch.Set "image" ($original.Fit $options) }}
|
||||||
|
{{ else if eq $command "Resize"}}
|
||||||
|
{{ .Scratch.Set "image" ($original.Resize $options) }}
|
||||||
|
{{ else if eq $command "Fill"}}
|
||||||
|
{{ .Scratch.Set "image" ($original.Fill $options) }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $image := .Scratch.Get "image" }}
|
||||||
|
|
||||||
|
{{ if .Inner }}
|
||||||
|
<figure>
|
||||||
|
<img src="{{ $image.Permalink }}" class='{{ .Get "class" }}' />
|
||||||
|
<figcaption>
|
||||||
|
<small>{{ .Inner }}</small>
|
||||||
|
</figcaption>
|
||||||
|
</figure>
|
||||||
|
{{ else }}
|
||||||
|
<img src="{{ $image.Permalink }}" class='{{ .Get "class" }}' />
|
||||||
|
{{ end }}
|
Loading…
Reference in a new issue