Subscribe to my blog
You can now subscribe to my blog by email!
This is by far the most complex thing I have implemented on this website. By ‘I’, I of course mean that most of it was done by Claude. It’s almost 2000 lines of code and I don’t have much more than a high level overview of how it all works.
The service uses Resend to automatically send emails. I keep track of subscriptions using a database on Cloudflare.
Here are some of the considerations when creating this tool:
- What happens if I publish an article and take it down? What if I put it back up again?
- When I run it for the first time or re-deploy the workers, will it re-send all of the old articles?
- How to handle unsubscribing/resubscribing?
- How to handle GDPR compliance?
- Is it safe from attacks/injections/bots?
- How do I test the emails myself?
- How do I style the email to match the website?
- How do I include SVG diagrams and equations?
- What do I do with the interactive components?
I have a bunch of fail-safes and tests included so I can be as sure as I can that it is reliable, but I am trusting Opus to a large extent. At least it made a manual on how to set up the workers, test, and deploy.
Other tools I’ve been able to implement include:
- Font subsetting: only keep the characters in the font files that are actually used in the document. This requires walking through all the statically generated pages, rendering the DOM, checking the styles of every text node, building the new font files and injecting them into the html files. This cuts the size of font files by almost a third.
- A script for dev mode that highlights a hovered HTML element when you hold alt and you can click it to go to the corresponding line in VSCode.
- Convert SVG to PNG files so they render in emails and RSS feeds. This requires walking through the DOM and injecting the computed CSS into the SVG elements before running them through the
sharplibrary. This also requires converting KaTeX text to valid MathJax, using MathJax to convert equations to SVG, then finally converting them into images. - Caching blog posts and SVG files so they don’t have to rebuild every time I change a file.
I predict we’ll be seeing a particular paradigm shift, as AI tools get cheaper and more capable. We are going to see more individuals and small businesses write in-house code to suit their particular needs, instead of going with monolithic do-everything companies that also charge for everything, and might be slow to change or fix things unless you are a well-paying customer. Programming jobs will pick back up again, but they will be more distributed towards internal software for small businesses instead of large tech companies.
Personally, I really like being able to have minimal reliance on other people’s tools and APIs. When all of the code is in my own repository, it makes it very easy to go fast and make the changes I want. I can have exactly the code that I need, and if there are any issues I can fix them myself.
Until Claude has an outage, that is, and then I’ll be stuck.