summaryrefslogtreecommitdiff
path: root/layouts/_default
diff options
context:
space:
mode:
authorNantha Sorubakanthan <nantha@mielota.com>2025-09-22 11:06:15 +0200
committerNantha Sorubakanthan <nantha@mielota.com>2025-09-22 11:06:15 +0200
commitef7c8c820916556fc5bff26c6ad7d12ef1606423 (patch)
treee6dbc68e081d43c6675591e1748f489833c8c05d /layouts/_default
parentc150f419a06e7bb006a4a71fa4e98faeb961037d (diff)
reworked the website
changed buttons, css, added first blog post
Diffstat (limited to 'layouts/_default')
-rwxr-xr-xlayouts/_default/_markup/render-image.html28
1 files changed, 27 insertions, 1 deletions
diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html
index 0a338b6..9bd482e 100755
--- a/layouts/_default/_markup/render-image.html
+++ b/layouts/_default/_markup/render-image.html
@@ -1 +1,27 @@
-<img src="{{ .Page.Permalink }}{{ .Destination }}"{{ with .Text }} alt="{{ . | safeHTML }}" title="{{ . | safeHTML }}"{{- end -}}>
+{{ $src := .Page.Resources.GetMatch (printf "%s" (.Destination | safeURL)) }}
+
+{{ if $src }}
+<figure>
+ {{ $data := newScratch }}
+
+ {{ if gt $src.Width 1100 }}
+ {{ $data.Set "webp" ($src.Resize "960x webp q90") }}
+ {{ $data.Set "fallback" ($src.Resize "960x q90") }}
+ {{ else }}
+ {{ $data.Set "webp" ($src.Resize (printf "%dx%d webp q90" $src.Width $src.Height)) }}
+ {{ $data.Set "fallback" ($src.Resize (printf "%dx%d q90" $src.Width $src.Height)) }}
+ {{ end }}
+
+ {{ $webp := $data.Get "webp" }}
+ {{ $fallback := $data.Get "fallback" }}
+
+ <a href="{{ $src }}">
+ <picture>
+ <source srcset="{{ $webp.RelPermalink }}" type="image/webp">
+ <img src="{{ $fallback.RelPermalink }}" alt="{{ .Text }}" loading="lazy" decoding="async" width="{{ $src.Width }}"
+ height="{{ $src.Height }}" />
+ </picture>
+ </a>
+ {{ with .Title }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
+</figure>
+{{end}}