summaryrefslogtreecommitdiff
path: root/layouts/shortcodes
diff options
context:
space:
mode:
authormms <michal@sapka.me>2024-04-22 15:42:24 +0200
committermms <michal@sapka.me>2024-04-22 15:42:24 +0200
commitdd2fa87bba4bb8c4c27e387773a49ee35445fa5d (patch)
tree2f703a988e3e4ce14ff21aa4dac379d68921f856 /layouts/shortcodes
parentd8930f1f3640e58731f2c20e4a2be0486b823f84 (diff)
feat: rating box:
Diffstat (limited to 'layouts/shortcodes')
-rw-r--r--layouts/shortcodes/rating.html34
1 files changed, 34 insertions, 0 deletions
diff --git a/layouts/shortcodes/rating.html b/layouts/shortcodes/rating.html
new file mode 100644
index 0000000..e6159ae
--- /dev/null
+++ b/layouts/shortcodes/rating.html
@@ -0,0 +1,34 @@
+{{- $rating := .Get 0 }}
+{{- $file := .Get 1 }}
+{{- $caption := .Inner }}
+
+<aside class="rating-box float-right">
+ <div class="poster">
+
+ {{- $path := printf "content_images/%s" $file}}
+ {{- $img := resources.Get $path }}
+ {{- $img1x := $img.Resize "170x webp" }}
+ {{- $img2x := $img.Resize "340x webp" }}
+
+ <img
+ alt="{{ $caption }}"
+ src="{{ $img1x.Permalink }}"
+ srcset="
+ {{ $img1x.Permalink }} 1x,
+ {{ $img2x.Permalink }} 2x
+ "
+ width="{{ $img1x.Width }}"
+ height="{{ $img1x.Height }}"
+ >
+
+ </div>
+ <div class="rating">
+ My rating:<br>
+
+ {{- range $i, $sequence := (seq 20) }}
+ {{- if le (mul $sequence 25) (mul $rating 100)}}&#9726;{{- else}}&#9725;{{- end }}
+ {{- end }}
+ <br>
+ <b>{{ $rating }}/5</b>
+ </div>
+</aside>