diff options
author | mms <michal@sapka.me> | 2024-04-22 15:42:24 +0200 |
---|---|---|
committer | mms <michal@sapka.me> | 2024-04-22 15:42:24 +0200 |
commit | dd2fa87bba4bb8c4c27e387773a49ee35445fa5d (patch) | |
tree | 2f703a988e3e4ce14ff21aa4dac379d68921f856 /layouts/shortcodes | |
parent | d8930f1f3640e58731f2c20e4a2be0486b823f84 (diff) |
feat: rating box:
Diffstat (limited to 'layouts/shortcodes')
-rw-r--r-- | layouts/shortcodes/rating.html | 34 |
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)}}◾{{- else}}◽{{- end }} + {{- end }} + <br> + <b>{{ $rating }}/5</b> + </div> +</aside> |