aboutsummaryrefslogtreecommitdiff
path: root/layouts/book/single.html
blob: f025d923fdebe1c1740d27b393815cbe750f5e01 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{{ define "main" }}
<div class="flex row gap-1">
    {{ if isset .Params "image" }}
    <figure>
    {{ with resources.GetRemote .Params.image }}
        {{ with .Err }}
            {{ errorf "%s" . }}
        {{ else }}
            {{ $image := . }}
            {{ $image := $image.Resize "250x" }}
            <img
                src="{{ $image.RelPermalink }}"
                width="{{ $image.Width }}"
                height="{{ $image.Height }}"
                alt="Book cover of the book {{ .Title }}"
            />
        {{ end }}
    {{ else }}
        {{ errorf "unable to get remote resource %q" .Params.image }}
    {{ end }}
        <figcaption>
        </figcaption>
    </figure>
    {{ end }}
    <div class="book-notes">
        <hgroup>
            <h1>{{ .Title }}</h1>
            {{ with .Params.last_read }}
            {{ $last := index (.) 0 }}
            {{/* if last_read is an array get the first item */}}
            <h6>Finished on: {{ $last | time.Format ":date_full" }}</h6>
            {{ end }}
            <h6>Rating:
            {{ if isset .Params "rating" }}
            {{ $rating := .Params.rating }}
            {{ range (seq $rating) }}
            ⭐
            {{ end }}
            {{ $diff := sub 5 $rating }}
            {{ range (seq $diff) }}
            ☆
            {{ end }}
            {{ else }}
                N/A
            {{ end }}
            </h6>
            {{ if isset .Params "amazon" }}
            <h6>Links:
                <a href="{{ .Params.amazon }}" target="_blank">Amazon</a>
            </h6>
            {{ end }}
        </hgroup>
        {{- .Content -}}
    </div>
</div>
{{ end }}