{{ define "main" }} {{ partial "header.html" . }}
{{ $scratch := newScratch }} {{ $posts := where site.RegularPages "Type" "blog" }} {{ range last 1 $posts }} {{ $numYears := div (sub now.Unix .Date.Unix) 31536000 }} {{ $firstDate := .Date.Format "January 2, 2006"}} {{ $scratch.Set "firstDate" $firstDate}} {{ $scratch.Set "numYears" $numYears }} {{ end }} {{ range first 1 $posts }} {{ $latestDate := .Date.Format "January 2, 2006"}} {{ $scratch.Set "latestDate" $latestDate }} {{ end }} {{ $postCount := len $posts }}

My most recent blog post was written on {{ $scratch.Get "latestDate" }} with my first ever one written on {{ $scratch.Get "firstDate" }}. This means I've been publishing for {{ $scratch.Get "numYears"}} years! Over which I have written a total of {{ $postCount }} posts.

{{ .Content }} {{ $tags := .Site.Taxonomies.tags }} {{ $scratch.Set "longCount" 0 }} {{ range $posts }} {{ $scratch.Add "wordcount" .WordCount }} {{ if ge .WordCount ($scratch.Get "longCount") }} {{ $scratch.Set "longestPost" . }} {{ $scratch.Set "longCount" .WordCount }} {{ end }} {{ end }} {{ $mostPopularTag := index .Site.Taxonomies.tags.ByCount 0 }} {{ $wordCount := $scratch.Get "wordcount" }} {{ $avgPostLength := div $wordCount $postCount }}
Total Words Written {{ $wordCount | lang.FormatNumberCustom 0 }}
Average Words per Post {{ $avgPostLength | lang.FormatNumberCustom 0 }}
Number of Topics {{ len $tags | lang.FormatNumberCustom 0 }}
Most Popular Topic {{ with $mostPopularTag }} {{ .Page.Title }} with {{ .Count }} posts {{ end }}
Longest Post Published {{ with $scratch.Get "longestPost" }} {{ .Title }} with {{ .WordCount }} words {{ end }}
Total Wikipedia Edits {{ $data := getJSON "https://en.wikipedia.org/w/api.php?action=query&list=users&ususers=BrandonRozek&usprop=editcount&format=json" }} {{ range first 1 $data.query.users }} {{ .editcount }} {{ end }}
Total OpenStreetMap Edits {{ $data := getJSON "https://api.openstreetmap.org/api/0.6/user/16068861.json" }} {{ $data.user.changesets.count }}
{{ $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" }}
{{ end }}