A Stats Page

Fun with blog data!

I’d like to briefly draw your attention to a new page on my site: the stats page!

This is a new thing I’ve added simply to see if I can. It’s done using a Hexo generator which compiles all of the stats about the site then passes them into a template to be nicely rendered. Hexo generators essentially can render anything to a file (mostly JSON, which is how the Lunr stuff works), but can also render a template. It’s all done at build-time, too.

Now you can see how much I’ve written here (over 100k words at this time!) and how often I post (not enough). I’m hoping that having these stats around will encourage me to write more posts and to keep them small. The average post is over 1k words which seems way to large.

Figuring out that Hexo generator was a pain. The documentation does a great job of letting you know you can render templates from a generator and shows examples of doing so. What they don’t show is how to access the value of the return object’s data property in the template. What I learned, from digging around the source code of the Stir Trek site (of course), is that the value of that data property is exposed as the page object within the template.

Hexo’s documentation leaves a lot to be desired.

The charts are built using Chartist. It’s a nice-enough plugin for this sort of thing. I like the use of musical intervals to denote various aspect ratios, though that’s not a very intuitive approach. Overall it’s a fine library, though I’m mostly using it because of how small it is. If I wanted more customization then I would look elsewhere.

Photo by Luke Chesser on Unsplash.