A bloggier unblogging tool.
Last night, I had the idea to create an "unblog": A blog without an index, RSS feed, or really anything other than a permalink for each post. The biggest downside of my original setup was not being able to generate
To solve this rather glaring issue, I turned to AWS Lambda. I'm pretty new to Lambda, so I was surprised how quickly I was able to put something together that did the trick. Since Lambda functions can be triggered by S3 events, that seemed like a good place to start.
Once I had that set up, it was just a matter of generating the right information at the right time. After fetching the page from S3, the function feeds it to jsdom in order to create an editable DOM. Once the function has a DOM, it converts the content of the
main element to an MD5 hash, and compares it against the existing value (if present), which is stored in a
If that value hasn't changed, nothing else has to be done, and the function exits. If the content hashes are different, the function generates/updates all the
og tags and saves the new HTML back to S3 at the same key.
Once the updated HTML has been saved back to S3, the function finally sends a DELETE request to Cloudflare to clear the post's cache.
Since this function fires on the
s3::putObject, there are a couple side-effects. First off, it means any time I update a previous post, it will automatically regenerate its metadata and clear its cache, which is super neat. The small downside is that the function will be run twice for every update, since it saving back to S3 will retrigger the function. Thankfully, that second run is inexpensive, and won't cause an infinite loop due to the MD5 content hash check.
So far, I'm really happy with this little "unblog". For updates, make sure to follow me on Twitter. I'd also love to hear your thoughts! 👋