mirror of
https://github.com/Brandon-Rozek/website-theme.git
synced 2024-12-22 21:23:57 +00:00
Removed shortest post from stats added year count
This commit is contained in:
parent
5a3139fbc4
commit
5e60c49e0b
1 changed files with 10 additions and 17 deletions
|
@ -9,10 +9,9 @@
|
|||
{{ $posts := where site.RegularPages "Type" "blog" }}
|
||||
|
||||
{{ $postCount := len $posts }}
|
||||
|
||||
|
||||
{{ $scratch := newScratch }}
|
||||
{{ $scratch.Set "longCount" 0 }}
|
||||
{{ $scratch.Set "shortCount" 9999999999 }}
|
||||
{{ range $posts }}
|
||||
<!-- Sum words for average calculation later -->
|
||||
{{ $scratch.Add "wordcount" .WordCount }}
|
||||
|
@ -21,11 +20,6 @@
|
|||
{{ $scratch.Set "longestPost" . }}
|
||||
{{ $scratch.Set "longCount" .WordCount }}
|
||||
{{ end }}
|
||||
<!-- Find shortest post -->
|
||||
{{ if le .WordCount ($scratch.Get "shortCount") }}
|
||||
{{ $scratch.Set "shortestPost" . }}
|
||||
{{ $scratch.Set "shortCount" .WordCount }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
<!-- Most Popular tag -->
|
||||
|
@ -35,8 +29,15 @@
|
|||
{{ $avgPostLength := div $wordCount $postCount }}
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td width="40%">Total Posts Published</td>
|
||||
<td width="60%">{{ $postCount | lang.NumFmt 0 }}</td>
|
||||
{{ range last 1 $posts }}
|
||||
{{ $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>
|
||||
<td>Total Words Written</td>
|
||||
|
@ -66,14 +67,6 @@
|
|||
{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Shortest Post Published</td>
|
||||
<td>
|
||||
{{ with $scratch.Get "shortestPost" }}
|
||||
<a href="{{ .Permalink }}">{{ .Title }}</a> with {{ .WordCount }} words
|
||||
{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{{ $grouped := $posts.GroupByDate "2006" }}
|
||||
|
|
Loading…
Reference in a new issue