Welcome to mirror list, hosted at ThFree Co, Russian Federation.

insertFigure.html « shortcodes « layouts - github.com/AmazingRise/hugo-theme-diary.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b9cd01550758afbf881100396660a7619841fa29 (plain)
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
32
33
34
<!--
    From "cupper-hugo-theme" by zwbetz-gh
    https://github.com/zwbetz-gh/cupper-hugo-theme/blob/master/layouts/shortcodes/figureCupper.html
    Under MIT License
-->
{{ $img := .Get "img" }}
{{ $caption := .Get "caption" }}
{{ $command := .Get "command" }}
{{ $options := .Get "options" }}
{{ $align := .Get "align" }}

{{ $original := .Page.Resources.GetMatch (printf "*%s*" $img) }}
{{ $new := "" }}

{{ if eq $command "Fit" }}
  {{ $new = $original.Fit $options }}
{{ else if eq $command "Fill" }}
  {{ $new = $original.Fill $options }}
{{ else if eq $command "Resize" }}
  {{ $new = $original.Resize $options }}
{{ else if eq $command "Original" }}
  {{ $new = $original }}
{{ else }}
  {{ errorf "Invalid image processing command: Must be one of Fit, Fill, Resize, Original." }}
{{ end }}

<figure align="{{$align}}" role="group" aria-describedby="caption-{{ $caption | md5 }}">
  <a href="{{ $original.RelPermalink }}" class="img-link">
    <img src="{{ $new.RelPermalink }}">
  </a>
  <figcaption id="caption-{{ $caption | md5 }}">
    {{ $caption | markdownify }}
  </figcaption>
</figure>