aboutsummaryrefslogtreecommitdiff
path: root/themes/hugo-pt2021/layouts/_default/archive.html
blob: 5da6ae87f6c3ab04bc3516f721e310d1525242f5 (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
59
60
61
{{- define "title" -}}
  {{- .Title -}}
{{- end -}}

{{- define "main" -}}
  <div class='container'>
    <div class='section is-small'>
      <h1 class='title'>
        {{- .Title -}}
      </h1><!-- title -->

      <div class='content'>
        {{/* get all published posts */}}
        {{- $posts := where .Site.RegularPages "Section" "posts" -}}

        {{/* loop through posts by year */}}
        {{- range $posts.GroupByDate "2006" -}}
          {{/* get year of first post (there will always be at least one) */}}
          {{- $head := index .Pages 0 -}}
          {{- $year := $head.Date.Format "2006" -}}

          <h2
            id='{{$year}}'
            title='Posts published in {{$year}}.'
            aria-label='Posts published in {{$year}}.'
          >
            {{- $year -}}
          </h2>

          <ul>
            {{/* loop through posts from this year */}}
            {{- range .Pages -}}
              <li>
                {{/* post link */}}
                <a
                  href='{{.Permalink}}'
                  title='{{.Title}}'
                  aria-label='{{.Title}}'
                >
                  {{- .Title -}}
                </a> -

                {{/* post date */}}
                <span
                  class='date'
                  title='Date for "{{.Title}}".'
                  aria-label='Date for "{{.Title}}".'
                >
                  {{- .Date.Format "January 2, 2006" -}}
                </span><!-- date -->
              </li>
            {{- end -}}
          </ul>
        {{- else -}}
          {{/* no published posts */}}
          No posts found.
        {{- end -}}
      </div><!-- content -->
    </div><!-- section -->
  </div><!-- container -->
{{- end -}}