diff options
-rw-r--r-- | layouts/partials/blog/archive.html | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/layouts/partials/blog/archive.html b/layouts/partials/blog/archive.html index fc61331..21e1a4a 100644 --- a/layouts/partials/blog/archive.html +++ b/layouts/partials/blog/archive.html @@ -1,6 +1,11 @@ <section> {{ $prev := now.Format "2006"}} <!--start from the current year--> - <h2 class="title is-2 top-pad">{{ $prev }}</h2> + {{ 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"}} @@ -16,4 +21,4 @@ {{ $prev = $curr}} {{end}} {{end}} -</section> +</section>
\ No newline at end of file |