That’s a fair number of files
I’ve been haphazardly attempting to organize my site files for a while. One thing I routinely need to know is what sort of content I’m working with.
I started with a Raku one-liner:
Not pretty, but quick and effective.
Unfortunately, it didn’t cover all the content extension once I figured out that Hugo can ignore *.txt
files, allowing me to try all sorts of tricks with content generation.
So I’ve had this Ruby code embedded in my justfile.
More verbose than the Raku solution for sure, but much of that is making sure it looks nice in a TTY Table.
It works! It’s great. Nothin wrong with it whatsoever.
But I’ve been looking at Node.js recently for assorted reasons, including the possibility of porting this site to one of the many Node-based static site generators.
So why not try the task in Node.js?
I’m only now attempting to use the platform with any kind of seriousness, so I apologize if there’s anything in there that’s not quite idiomatic.
I grabbed glob to simplify the task of recursively drilling down into content/
. Array.reduce
helps me count files matching each of my content extensions, then construct an object with those tallies. Since Console.table
comes standard, I didn’t need to dig for any formatting libraries today.
Though I might later for a little more control over display.
But hey it works.
Backlinks
Got a comment? A question? More of a comment than a question?
Talk to me about this page on: mastodon
Added to vault 2024-01-15. Updated on 2024-02-02