Removed shortest post from stats added year count

This commit is contained in:
Brandon Rozek 2022-12-18 01:55:47 -05:00
parent 5a3139fbc4
commit 5e60c49e0b
No known key found for this signature in database
GPG key ID: 26E457DA82C9F480

View file

@ -12,7 +12,6 @@
{{ $scratch := newScratch }} {{ $scratch := newScratch }}
{{ $scratch.Set "longCount" 0 }} {{ $scratch.Set "longCount" 0 }}
{{ $scratch.Set "shortCount" 9999999999 }}
{{ range $posts }} {{ range $posts }}
<!-- Sum words for average calculation later --> <!-- Sum words for average calculation later -->
{{ $scratch.Add "wordcount" .WordCount }} {{ $scratch.Add "wordcount" .WordCount }}
@ -21,11 +20,6 @@
{{ $scratch.Set "longestPost" . }} {{ $scratch.Set "longestPost" . }}
{{ $scratch.Set "longCount" .WordCount }} {{ $scratch.Set "longCount" .WordCount }}
{{ end }} {{ end }}
<!-- Find shortest post -->
{{ if le .WordCount ($scratch.Get "shortCount") }}
{{ $scratch.Set "shortestPost" . }}
{{ $scratch.Set "shortCount" .WordCount }}
{{ end }}
{{ end }} {{ end }}
<!-- Most Popular tag --> <!-- Most Popular tag -->
@ -35,8 +29,15 @@
{{ $avgPostLength := div $wordCount $postCount }} {{ $avgPostLength := div $wordCount $postCount }}
<table class="table"> <table class="table">
<tr> <tr>
<td width="40%">Total Posts Published</td> {{ range last 1 $posts }}
<td width="60%">{{ $postCount | lang.NumFmt 0 }}</td> {{ $numYears := div (sub now.Unix .Date.Unix) 31536000 }}
<td width="40%">Years Blogging</td>
<td width="60%">{{ $numYears | lang.NumFmt 0 }}</td>
{{ end }}
</tr>
<tr>
<td>Total Posts Published</td>
<td>{{ $postCount | lang.NumFmt 0 }}</td>
</tr> </tr>
<tr> <tr>
<td>Total Words Written</td> <td>Total Words Written</td>
@ -66,14 +67,6 @@
{{ end }} {{ end }}
</td> </td>
</tr> </tr>
<tr>
<td>Shortest Post Published</td>
<td>
{{ with $scratch.Get "shortestPost" }}
<a href="{{ .Permalink }}">{{ .Title }}</a> with {{ .WordCount }} words
{{ end }}
</td>
</tr>
</table> </table>
{{ $grouped := $posts.GroupByDate "2006" }} {{ $grouped := $posts.GroupByDate "2006" }}