summaryrefslogtreecommitdiff
path: root/layouts/library/page.html
blob: 1e9753a51b6471b6d20fa47986ec7f659e60485b (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
57
58
{{ define "main" }}
    <article>
        <header class="flex flex-col items-center gap-2">
            <div class="relative border-3 border-solid border-white shadow-lg w-[10rem] md:w-[15rem]"
                style="view-transition-name: book-{{ .File.UniqueID }}">
                <img
                    class="lazy block w-full h-auto" loading="lazy"
                    data-pagefind-meta="image[src]"
                    src="{{ .Params.cover }}"
                />
                {{ partial "components/logo"
                (dict
                    "link" "library"
                    "class" "round-sticker absolute w-8 h-8 md:w-20 md:h-20 top-8 -right-8 md:-right-12"
                    "imageClass" "w-full") }}
            </div>
            <h1 class="xerox" data-pagefind-meta="title">{{ .Title }}</h1>
            {{- $rating := .Params.rating -}}
            {{- $fullStars := math.Floor $rating -}}
            <p class="m-0">
                {{ .Params.author }}
            </p>
            <p class="m-0">
                {{- range seq $fullStars }}
                <span class="star">⭐</span>
                {{- end -}}
            </p>
        </header>

        <div class="markdown-body leading-loose">
            {{ partial "posts/toc" . }}
            <div>{{ .Content }}</div>
            {{ partial "posts/endnotes" . }}
        </div>

        <div class="text-size-base text-secondary md:flex md:justify-between">
            <p>于 {{ partial "components/date" . }} 读完</p>
            <p>{{ partial "components/tags" . }}</p>
        </div>

        {{ partial "components/backlinks" (dict "filename" .File.BaseFileName "type" "library" "context" .) }}
        {{ partial "posts/action-menu.html" . }}
        {{ partial "components/back-to-top.html" . }}

        {{ $books := where (where .Site.RegularPages "Section" "library") ".Params.author" "==" .Params.author }}
        {{ $thisBookID := .File.UniqueID }}
        {{ if gt (len $books) 1 }}
            <h2>我读过的{{ .Params.author }}的其它书籍</h2>
            <div class="grid grid-cols-4 md:grid-cols-6 items-center gap-4 my-4">
            {{ range $books }}
                {{ if ne .File.UniqueID $thisBookID }}
                <div data-tooltip="{{ .Title }}">{{ partial "items/book" . }}</div>
                {{ end }}
            {{ end }}
            </div>
        {{ end }}
    </article>
{{ end }}