aboutsummaryrefslogtreecommitdiff
path: root/layouts/_default/section.html
blob: 8e5edf100ac5e47bf2d1cd136e5df9d9fe3de80d (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
{{ define "title" }}{{ T "archive" }} - {{ .Site.Title }}{{ end }}

{{ define "content"}}
{{- $paginator := .Paginate (where .Data.Pages.ByDate.Reverse "Type" "post") (index .Site.Params "archive-paginate") }}
<section id="archive" class="archive">
  {{- if not $paginator.HasPrev }}
    <div class="archive-title">
      <span class="archive-post-counter">
        {{ T "archiveCounter" (len .Data.Pages) }}
      </span>
    </div>
  {{- end -}}

  {{- range $index, $element := $paginator.Pages -}}
    {{- $thisYear := $element.Date.Format "2006" }}
    {{- $lastElement := $index | add -1 | index $paginator.Pages }}
    {{ if or (eq $index 0) ( ne ($lastElement.Date.Format "2006") $thisYear ) }}
      <div class="collection-title">
        <h2 class="archive-year">{{ $thisYear }}</h2>
      </div>
    {{- end }}

    <div class="archive-post">
      <span class="archive-post-time">
        {{ $element.Date.Format "01-02" }}
      </span>
      <span class="archive-post-title">
        <a href="{{ $element.URL }}" class="archive-post-link">
          {{ .Title }}
        </a>
      </span>
    </div>
  {{- end -}}
</section>
<!-- pagination -->
<nav class="pagination">
  {{ with $paginator.Prev -}}
    <a class="prev" href="{{ .URL }}">
      <i class="iconfont icon-left"></i>
      <span class="prev-text">{{ T "prevPage" }}</span>
    </a>
  {{- end }}
  {{ with $paginator.Next -}}
    <a class="next" href="{{ .URL }}">
      <span class="next-text">{{ T "nextPage" }}</span>
      <i class="iconfont icon-right"></i>
    </a>
  {{- end }}
</nav>
{{ end }}