32 lines
1.5 KiB
HTML
32 lines
1.5 KiB
HTML
|
<li>
|
||
|
<a href="{{.Permalink}}">
|
||
|
<time class="post-date" datetime="{{ .Date.Format `2006-01-02T15:04:05Z07:00` | safeHTML }}">
|
||
|
{{ .Date.Day }} {{ index $.Site.Data.months_fr (printf "%d" .Date.Month) }} {{ .Date.Year }}
|
||
|
</time>
|
||
|
|
|
||
|
<!--
|
||
|
Well, I am a beginner with Hugo so this is probably like crushing a banana with a rocket.
|
||
|
When a post belongs to a "case" (i.e. a section with a code, I'd like to have [INDEX/TOTAL] printed in title.
|
||
|
An when a post is on its own, don't print anything.
|
||
|
A little bit like : https://www.hacking-social.com/
|
||
|
But I don't wan't to write it manually because it could break when adding a blog post in between two existing blog posts.
|
||
|
So, iterate over the blog posts with same section as current blog post, order them by date and save the index of current blog post.
|
||
|
Maybe there is an easier way to get the same result...
|
||
|
-->
|
||
|
{{ $currentPost := . }}
|
||
|
{{ $currentPostIndex := 1 }}
|
||
|
{{ $posts := (where $.Site.RegularPages "CurrentSection.Params.Code" "==" $.CurrentSection.Params.Code )}}
|
||
|
{{ $postsSorted := (sort $posts "Date" )}}
|
||
|
{{ $postCounts := len $postsSorted }}
|
||
|
{{ range $index, $element := $postsSorted }}
|
||
|
{{ if eq $element.Title $currentPost.Title }}
|
||
|
{{ $currentPostIndex = (add $index 1) }}
|
||
|
{{ end }}
|
||
|
{{ end }}
|
||
|
{{ with .CurrentSection.Params.Code }}
|
||
|
[{{ . }} {{ print $currentPostIndex }}/{{ print $postCounts }}]
|
||
|
{{ end }}
|
||
|
{{ .Title }}
|
||
|
</a>
|
||
|
</li>
|