Welcome to mirror list, hosted at ThFree Co, Russian Federation.

archive.html « blog « partials « layouts - github.com/vickylaixy/hugo-theme-introduction.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a98b97b936c19f9dfc87a43d2dd3f0a47cf2735d (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
<section>
    {{ $prev := now.Format "2006"}}
    <!--start from the current year-->
    {{ range first 1 .Pages.ByPublishDate.Reverse }}
    {{if .Date}}
    <!--also add the header if there are posts during the current year-->
    {{if eq $prev (.Date.Format "2006")}}
    <h2 class="title is-2 top-pad"> {{ $prev }}</h2> {{end}}
    {{end}}
    {{end}}

    {{range .Pages.ByPublishDate.Reverse}}
    {{if .Date}}
    {{$curr := .Date.Format "2006"}}
    {{if lt $curr $prev }}
    <h2 class="title is-2 top-pad">{{ $curr }}</h2>
    {{end}}
    <li class="post-item">
        {{ if .Params.date }}
        <span>{{ .Date.Format (.Site.Params.dateFormat | default ":date_medium") }}</span> -
        {{ end }}
        <span><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></span>
    </li>
    {{ $prev = $curr}}
    {{end}}
    {{end}}
</section>