diff options
author | Christoph Cullmann <christoph@cullmann.io> | 2024-06-26 21:44:28 +0200 |
---|---|---|
committer | Christoph Cullmann <christoph@cullmann.io> | 2024-06-26 21:44:28 +0200 |
commit | 58e2c9ae87f09dac79ecf962331ae2c51f4ba7f1 (patch) | |
tree | d819d1747427f81d1883a715ec60d13d575053e4 /themes/blowfish/layouts/shortcodes/figure.html | |
parent | b1a7697b03cfb0143af78993387f758836e842bf (diff) |
update the theme
Diffstat (limited to 'themes/blowfish/layouts/shortcodes/figure.html')
-rw-r--r-- | themes/blowfish/layouts/shortcodes/figure.html | 97 |
1 files changed, 46 insertions, 51 deletions
diff --git a/themes/blowfish/layouts/shortcodes/figure.html b/themes/blowfish/layouts/shortcodes/figure.html index 4f641f3..fb7293c 100644 --- a/themes/blowfish/layouts/shortcodes/figure.html +++ b/themes/blowfish/layouts/shortcodes/figure.html @@ -2,54 +2,49 @@ {{ if .Get "default" }} {{ template "_internal/shortcodes/figure.html" . }} {{ else }} - {{ $url := urls.Parse (.Get "src") }} - {{ $altText := .Get "alt" }} - {{ $caption := .Get "caption" }} - {{ $href := .Get "href" }} - {{ $class := .Get "class" }} - {{ $target := .Get "target" }} - {{ $nozoom := .Get "nozoom" | default false }} - {{ if findRE "^https?" $url.Scheme }} - <figure> - <img class="my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" /> - {{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }} - </figure> - {{ else }} - {{ $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 }} - <figure {{ with $class }}class="{{ . }}"{{ end }}> - {{ with $href }}<a href="{{ . }}" {{ with $target }}target="{{ . }}"{{ end }}>{{ end }} - {{ if $disableImageOptimization }} - <img - class="my-0 rounded-md{{ if $nozoom }} nozoom{{ end }}" - src="{{ .RelPermalink }}" - alt="{{ $altText }}" - /> - {{ else }} - <img - class="my-0 rounded-md{{ if $nozoom }} nozoom{{ end }}" - srcset=" - {{ (.Resize "330x").RelPermalink }} 330w, - {{ (.Resize "660x").RelPermalink }} 660w, - {{ (.Resize "1024x").RelPermalink }} 1024w, - {{ (.Resize "1320x").RelPermalink }} 2x" - src="{{ (.Resize "660x").RelPermalink }}" - alt="{{ $altText }}" - /> - {{ end }} - {{ if $href }}</a>{{ end }} - {{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }} - </figure> - {{ else }} - <figure> - <img class="my-0 rounded-md{{ if $nozoom }} nozoom{{ end }}" src="{{ $url.String }}" alt="{{ $altText }}" /> - {{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }} - </figure> - {{ end }} - {{ end }} -{{ end }} + {{- $url := urls.Parse (.Get "src") }} + {{- $altText := .Get "alt" }} + {{- $caption := .Get "caption" }} + {{- $href := .Get "href" }} + {{- $class := .Get "class" }} + {{- $target := .Get "target" | default "_blank" }} + {{- $nozoom := .Get "nozoom" | default false -}} + + <figure> + {{- with $href }}<a href="{{ . }}" {{ with $target }}target="{{ . }}"{{ end }}>{{ end -}} + {{- if findRE "^https?" $url.Scheme }} + <img class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}" src="{{ $url.String }}" alt="{{ $altText }}" /> + {{- else }} + {{- $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 }} + {{- if or $disableImageOptimization (eq .MediaType.SubType "svg")}} + <img + class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}" + src="{{ .RelPermalink }}" + alt="{{ $altText }}" + /> + {{- else }} + <img + class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}" + srcset=" + {{ (.Resize "330x").RelPermalink }} 330w, + {{ (.Resize "660x").RelPermalink }} 660w, + {{ (.Resize "1024x").RelPermalink }} 1024w, + {{ (.Resize "1320x").RelPermalink }} 2x" + src="{{ (.Resize "660x").RelPermalink }}" + alt="{{ $altText }}" + /> + {{- end }} + {{- else }} + <img class="my-0 rounded-md{{ with $nozoom }} nozoom{{ end }}{{ with $class }} {{ . }}{{ end }}" src="{{ $url.String }}" alt="{{ $altText }}" /> + {{- end }} + {{- end }} + {{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }} + {{ if $href }}</a>{{ end }} + </figure> +{{- end -}} |