2022-02-03 00:37:09 +00:00
|
|
|
{{ if .Get "default" }}
|
|
|
|
{{ template "_internal/shortcodes/figure.html" . }}
|
2022-01-12 03:21:22 +00:00
|
|
|
{{ else }}
|
2022-02-06 00:26:37 +00:00
|
|
|
{{ $url := urls.Parse (.Get "src") }}
|
2022-02-03 00:37:09 +00:00
|
|
|
{{ $altText := .Get "alt" }}
|
|
|
|
{{ $caption := .Get "caption" }}
|
|
|
|
{{ $href := .Get "href" }}
|
|
|
|
{{ $class := .Get "class" }}
|
2022-02-06 00:26:37 +00:00
|
|
|
{{ if findRE "^https?" $url.Scheme }}
|
|
|
|
<figure>
|
|
|
|
<img class="my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" />
|
2022-02-03 00:37:09 +00:00
|
|
|
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
|
|
|
</figure>
|
|
|
|
{{ else }}
|
2022-03-07 22:51:19 +00:00
|
|
|
{{ $resource := "" }}
|
|
|
|
{{ if $.Page.Resources.GetMatch ($url.String) }}
|
|
|
|
{{ $resource = $.Page.Resources.GetMatch ($url.String) }}
|
|
|
|
{{ else if resources.GetMatch ($url.String) }}
|
|
|
|
{{ $resource = resources.Get ($url.String) }}
|
|
|
|
{{ end }}
|
|
|
|
{{ with $resource }}
|
2022-02-06 00:26:37 +00:00
|
|
|
<figure {{ with $class }}class="{{ . }}"{{ end }}>
|
|
|
|
{{ with $href }}<a href="{{ . }}">{{ end }}
|
|
|
|
<img
|
|
|
|
class="my-0 rounded-md"
|
|
|
|
srcset="
|
|
|
|
{{ (.Resize "330x").RelPermalink }} 330w,
|
|
|
|
{{ (.Resize "660x").RelPermalink }} 660w,
|
|
|
|
{{ (.Resize "1024x").RelPermalink }} 1024w,
|
|
|
|
{{ (.Resize "1320x").RelPermalink }} 2x"
|
|
|
|
src="{{ (.Resize "660x").RelPermalink }}"
|
|
|
|
alt="{{ $altText }}"
|
|
|
|
/>
|
|
|
|
{{ if $href }}</a>{{ end }}
|
|
|
|
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
|
|
|
</figure>
|
|
|
|
{{ else }}
|
2022-03-07 22:51:19 +00:00
|
|
|
<figure>
|
|
|
|
<img class="my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" />
|
|
|
|
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
|
|
|
</figure>
|
2022-02-06 00:26:37 +00:00
|
|
|
{{ end }}
|
2022-02-03 00:37:09 +00:00
|
|
|
{{ end }}
|
|
|
|
{{ end }}
|