The technicalities of blogging

So, this blog's been up and running for a short while, and only had 2 posts. It's a very basic NextJS project, but I've already been keen to optimise the 'behind the scenes' element of it.

For example, when I first created the blog, I had a node script which would detect when a file was created, and use that when building to generate the 'created at' time. The problem with this is what when you deploy the file, the attributes change. One deployment will have a different 'created at' time to the other, and you've no way of working around that directly.

This indirectly created another problem - the URL would change. Since I generated the URL 'hash' from known data, this would change between deployments, which means I was essentially creating dead-links with every deployment.

So, in my next iteration, I decided to use a metadata file. It was just JSON to begin with, and this worked well. The data would always remain the same, next would read it when building, and all was good in the world. Eventually, I decided to make this a typescript file which would calculate the hash at build-time, based upon the static metadata.

Again, this worked well, but in my ever-expanding quest to do more, I decided I might want to write blog posts from an N8N form so that I didn't have to clone the repo, add a file, run some scripts, etc.

So, I decided that the next logical step would be to start using a database. I'm absolutely not going to deploy a database, but using a local in-repo SQLite database? Yeah, that can work. It's not storing much, and it's not shipped to browsers. As I've mentioned before, one goal of this blog is to be entirely SSG. I'm not shipping MB of JS to clients, and so I'm also not shipping a few hundred KB SQLite DB to clients either.

To support this, I implemented some rudimentary data extraction from the markdown blog posts themselves, where I use the HTML comment tags to store the creation time.

Now, I've got part of my setup working. I've moved over to a couple of scripts - one which generates metadata based upon files and puts it into SQLite (runs before build), and another which loads the data from the DB (also runs during the Next page generation at build time).

What I don't have working (yet!) is the N8N parts, but mostly because I've been too busy to finish the workflow. I can create new files in the repo, and that'll deploy them properly, but I've not actually gone through and tested it properly. Each time I submit the N8N form, it tries to push a file, which seems to trigger a commit, which in turn triggers my page host to try to run a build.

I'm sure I'll figure it out eventually. I said this project wasn't going to stress me out, or take significant time once it was setup, and I'm maintaining that. I want blogging to be fun and no pressure.