aboutsummaryrefslogtreecommitdiff
path: root/layouts/book/list.html
blob: 346a918fba5a44e7790845991f8b142d9cc88e58 (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
{{ define "main" }}
  <article>
    <h1>{{ .Title }}</h1>
    {{ if .Content }}
      <p>{{- .Content -}}</p>
    {{ end }}
    <section>
      {{ if .IsSection }}
        {{ range sort (.Paginator 3).Pages "Date" "desc" }}
          {{ if ne .Layout "list" }}
            <div>{{ .Render "summary" }}</div>
          {{ end }}
        {{ end }}
      {{ else }}
        {{ $metric := .Params.sortby }}
        {{ $direction := "asc" }}
        {{ if eq .Params.sortby "rating" }}
          {{ $direction = "desc" }}
        {{ end }}
        {{ $pages := (where .Site.RegularPages "Type" "book") }}
        {{ $pages = (where $pages "Layout" "!=" "list")}}
        {{ if eq $direction "desc" }}
          {{ $pages = (sort ($pages.ByParam $metric).Reverse) }}
        {{ else }}
          {{ $pages = (sort ($pages.ByParam $metric)) }}
        {{ end }}
        {{ range $pages }}
          <div>{{ .Render "summary" }}</div>
        {{ end }}
      {{ end }}
    </section>
  </article>
{{ end }}