summaryrefslogtreecommitdiff
path: root/layouts/shortcodes/rating.html
blob: e6159aea57066420b0e68a5d3a0ae7b192bdb886 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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>