feat: stats page

This commit is contained in:
Cory Dransfeldt 2023-12-19 15:21:39 -08:00
parent 67677ff9d4
commit fa2c2ad514
No known key found for this signature in database
14 changed files with 495 additions and 155 deletions

View file

@ -8,7 +8,7 @@ permalink: /search.html
<link href="https://coryd.dev/pagefind/pagefind-ui.css" rel="stylesheet" />
<style>
:root {
--pagefind-ui-font: 'Seravek', 'Gill Sans Nova', 'Ubuntu', 'Calibri', 'DejaVu Sans', 'source-sans-pro', 'sans-serif';
--pagefind-ui-font: system-ui, sans-serif;
--pagefind-ui-primary: #374151;
--pagefind-ui-text: #374151;
}

22
src/pages/stats.html Normal file
View file

@ -0,0 +1,22 @@
---
title: Statistics
layout: default
permalink: /stats.html
---
<p>My first post was published on <strong class="highlight-text">{{ collections.postStats.firstPostDate | dateToReadableDate }}</strong> and my most recent one was published on <strong class="highlight-text">{{ collections.postStats.lastPostDate | dateToReadableDate }}</strong>. I've published <strong class="highlight-text">{{ collections.postStats.postCount }} posts</strong> containing <strong class="highlight-text">{{ collections.postStats.totalWordCount }} words</strong> and <strong class="highlight-text">{{ collections.postStats.totalCodeBlockCount }} code samples</strong>.</p>
<p>Posts have, on average, <strong class="highlight-text">{{ collections.postStats.avgWordCount | round }} words</strong> and a gap of <strong class="highlight-text">{{ collections.postStats.avgDays | round }} days</strong> between them.</p>
<h3>Popular posts</h3>
<ol class="list-inside pl-5 md:pl-10">
{% assign posts = collections.posts | getPopularPosts: analytics %}
{% for post in posts limit: 10 %}
<li class="mt-1.5 mb-2">
<a href="{{post.url}}" title="{{ post.data.title | escape}}">
{{ post.data.title }}
</a>
</li>
{% endfor %}
</ol>
<h3>Posts by year</h3>
{% render "partials/post-graph.liquid", postYears: collections.postStats.years %}
<h3>Post distribution graphs</h3>
{%- postGraph collections.posts -%}