12 February 2024

Reporting and recording with plaintext and SvelteKit

Like many hackers, I like keeping records in plain text files. A couple of examples I’m maintaining at the moment are:

As you can see, the formats are lax and idiosyncratic – they’re a reflection of my own thought processes plus some ad-hoc shortcuts to make things easier to type in.

This makes them unsuitable for viewing by other people, which is where SvelteKit comes in.


Instead of keeping these records inside an actual plaintext file, I keep them in a JavaScript template string inside a Svelte component inside a SvelteKit project. I use mdsvex along with Josh Collinsworth’s excellent SvelteKit + Markdown blog guide to get things like markdown support and automatic listing of pages: each file/report is a page/post.

The surrounding JavaScript, markup, and framework code transforms these ad-hoc records into whatever form I want to display them in. For work, I display the minute-by-minute records along with a summary for each day and an average for the reporting period. For the treatment costs, I break down everything by provider, trip, expense type, and so on. (The costs are integrated into my UK -> US Jaw Expansion Guide, which is also a SvelteKit project that I export as a PDF.)

This system lets you create and maintain your records as plain text—for your own viewing and editing, you can just open the .svelte or .md file—while also allowing you to quickly develop a custom reporting app around each file.


There are several advantages to this ad-hoc way of developing reports:


See example repo: sveltekit-reports. This includes a bunch of stuff from the blog project it was cloned from, so could be stripped down further.