summaryrefslogtreecommitdiff
path: root/layouts/_shortcodes/bookcard.html
blob: d128193b486c546eac6bd1387dc4f6bf1edf77a9 (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
{{- $books := where .Site.Pages "Section" "library" -}}
{{- $book := index (where $books "File.BaseFileName" (.Get 0)) 0 -}}

{{- if $book }}
    <div class="markdown-body">
        <div class="mx-auto max-w-[50%] ">
            <img class="block w-full" src="{{ $book.Params.cover }}" />
        </div>
        <h3 class="book-title">
            <a href="{{ $book.Permalink }}">{{ $book.Title }}</a>
        </h3>

        {{- $rating := $book.Params.rating -}}
        {{- $fullStars := math.Floor $rating -}}
        <div class="rating">
            <span>评分:</span>
            {{- range seq $fullStars }}
            <span class="star">★</span>
            {{- end -}}
        </div>

        <div class="book-content">
            {{ $book.Content }}
        </div>
    </div>
{{- else }}
    <p style="color: red;">⚠️ 无法找到书评: {{ .Get 0 }}</p>
{{- end }}