diff options
author | Angelo <AIRyndon@users.noreply.github.com> | 2020-12-26 10:19:01 +0300 |
---|---|---|
committer | Angelo <AIRyndon@users.noreply.github.com> | 2020-12-26 10:19:01 +0300 |
commit | c7afd15e0674ad6e54624d7fd992a161a9787514 (patch) | |
tree | 696bbbf3f13348c477fcafd2fb4f761f7c471ff8 /layouts | |
parent | 50d13c4e836ba15f817c4423b54be26f1be21e82 (diff) |
add check on the latest post year before inserting the h2
Diffstat (limited to 'layouts')
-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 |