mirror of
https://git.adityakumar.xyz/hugo-theme-introduction.git
synced 2024-12-22 22:52:54 +00:00
add check on the latest post year before inserting the h2
This commit is contained in:
parent
50d13c4e83
commit
c7afd15e06
1 changed files with 7 additions and 2 deletions
|
@ -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"}}
|
||||
|
|
Loading…
Reference in a new issue