aboutsummaryrefslogtreecommitdiff
path: root/layouts/book/single.html
blob: 9179523dc2439324a9a0073a78414c6c23bdf6f5 (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
{{ define "main" }}
    <hgroup>
        <h1>{{ .Title }}</h1>
        <h6>{{ .Date | time.Format ":date_full" }}</h6>
    </hgroup>
    {{ if isset .Params "image" }}
    {{ 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 }}
    {{ end }}
    <div class="flex row gap-1">
        <strong>Rating:</strong>
        {{ if isset .Params "rating" }}
        {{ $rating := .Params.rating }}
        {{ range (seq $rating) }}
        ⭐
        {{ end }}
        {{ $diff := sub 5 $rating }}
        {{ range (seq $diff) }}
        ☆
        {{ end }}
        {{ else }}
            <p>N/A</p>
        {{ end }}
    </div>
    {{ if isset .Params "amazon" }}
    <p>
        <a href="{{ .Params.amazon }}" target="_blank">amazon</a>
    </p>
    {{ end }}
    <div>
        {{- .Content -}}
    </div>
{{ end }}