summaryrefslogtreecommitdiff
path: root/layouts/library/section.html
blob: cd95b8e8d626541dc9069e654b7f7d53bb21d5b1 (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
{{ define "main" }}
  <article class="pagefind-exclude">
    {{ partial "header.html" . }}
    <div>
        <h2>{{ now.Year }} 年读的书</h2>
        <div class="grid grid-cols-4 md:grid-cols-6 items-center gap-4 my-4">
            {{ $books := first 18 (where .Site.RegularPages "Section" "library") }}
            {{ range $i, $book := $books }}
                {{ if eq .Date.Year now.Year }}
                <div class="{{ if gt $i 15 }}hidden md:block{{ end }}"
                    data-tooltip="{{ $book.Title }}">
                    {{ partial "items/book" $book }}
                </div>
                {{ end }}
            {{ end }}
        </div>

        {{ $years := slice }}
        {{ range where .Site.RegularPages "Section" "library" }}
        {{ $year := string .Date.Year }}
        {{ if not (in $years $year) }}
            {{ $years = $years | append $year }}
        {{ end }}
        {{ end }}


        <div class="flex items-center my-8">
            <a href="/library/2025" class="small-button">
                {{ T "library.viewAllThisYear" }}
                <span class="text-secondary">→</span>
            </a>
            <p class="my-0 mx-4">
              {{ $currentYear := printf "%d" now.Year }}
              {{ range $years }}
                {{ if ne . $currentYear }}<a class="text-secondary" href="{{ printf "/library/%s/" . }}">{{ . }} 年</a>{{ end }}
              {{ end }}
            </p>
        </div>

        <h2>推荐好书</h2>
        <div class="grid grid-cols-4 md:grid-cols-6 items-center gap-4 my-4">
        {{ range where (where .Site.RegularPages "Section" "library") ".Params.rating" "==" 5 }}
            <div data-tooltip="{{ .Title }}">{{ partial "items/book" . }}</div>
        {{ end }}
        </div>
    </div>
  </article>
  {{ partial "footer.html" . }}
{{ end }}