diff --git a/layouts/_default/single.html b/layouts/_default/single.html index c7ce0bd..1c3a4c4 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,4 +1,4 @@ -{{ define "main"}} +{{ define "main" }} {{ partial "header.html" . }}
{{ partial "date.html" . }} diff --git a/layouts/_default/stats.html b/layouts/_default/stats.html new file mode 100644 index 0000000..d275e95 --- /dev/null +++ b/layouts/_default/stats.html @@ -0,0 +1,113 @@ +{{ define "main" }} + +{{ partial "header.html" . }} +
+
+
+ {{ .Content }} + {{ $posts := where site.RegularPages "Type" "blog" }} + + {{ $postCount := len $posts }} + + {{ $scratch := newScratch }} + {{ $scratch.Set "longCount" 0 }} + {{ $scratch.Set "shortCount" 9999999999 }} + {{ range $posts }} + + {{ $scratch.Add "wordcount" .WordCount }} + + {{ if ge .WordCount ($scratch.Get "longCount") }} + {{ $scratch.Set "longestPost" . }} + {{ $scratch.Set "longCount" .WordCount }} + {{ end }} + + {{ if le .WordCount ($scratch.Get "shortCount") }} + {{ $scratch.Set "shortestPost" . }} + {{ $scratch.Set "shortCount" .WordCount }} + {{ end }} + {{ end }} + + {{ $wordCount := $scratch.Get "wordcount" }} + {{ $avgPostLength := div $wordCount $postCount }} + + + + + + + + + + + + + + + + + + + + + +
Total Posts Published{{ $postCount | lang.NumFmt 0 }}
Total Words Written{{ $wordCount | lang.NumFmt 0 }}
Average Words per Post{{ $avgPostLength | lang.NumFmt 0 }}
Longest Post Published + {{ with $scratch.Get "longestPost" }} + {{ .Title }} with {{ .WordCount }} words + {{ end }} +
Shortest Post Published + {{ with $scratch.Get "shortestPost" }} + {{ .Title }} with {{ .WordCount }} words + {{ end }} +
+ + {{ $grouped := $posts.GroupByDate "2006" }} + +

Posts Per Year

+ +
+ + +
+ + + + {{ $chartPre := "{type: 'line',data: {labels: [" }} + {{ $chartYearKeys := trim ($scratch.Get "yearKeys") ","}} + {{ $chartYearCount := trim ($scratch.Get "yearCount") ","}} + {{ $chartMid := "],datasets: [{label: 'Posts Published',data: [" }} + {{ $chartPost := "],backgroundColor: 'rgb(54, 128, 56)',borderColor: 'rgb(54, 128, 56)',borderWidth: 3}]},options: {maintainAspectRatio: false, animation: false, scales: {y: {ticks: {beginAtZero: true}}}}}" + }} + + + {{ $chartData := printf "%s" $chartPost | printf "%s%s" $chartYearCount | printf "%s%s" $chartMid | printf "%s%s" $chartYearKeys | printf "%s%s" $chartPre | printf "%s" }} + + + +
+
+
+{{ partial "footer.html" . }} +{{ end }}