Finished the item hash link feature
2024-12-02 14:34:00 +07:00 by Mark Smith
A quick post to celebrate a small win. It’s been an uphill struggle for this feature on the website for many weeks at this point. I realised a couple of months back that with the new everything main page, which shows all post types interleaved, that it was in some cases really difficult to figure out where the end of a post and the beginning of the next post was.
This was particularly obvious when a notes post followed a blog post, or a newsletter post. At the time I was up against running out of build minutes, so I implemented a temporary workaround. The workaround, which was to have post delimiters was functional, but it was also kind of geek cool, because the delimiters were inspired by bash heredocs.
The longer term solution though was to ensure that all posts had a hash link at the end. Notes and link items already had these, but blog, newsletter and podcast posts didn’t. But I could see that it would likely involve quite a lot of work since it required changes in all the plugins, hence the workaround. I had initially planned to add the hash link outside the plugin components, but that turned out to be essentially impossible using current HTML and CSS. I wasted quite a lot of time fuguring that out.
The second attempt was a simpler solution. Instead of adding the hash link outside the plugin, just generate the url for the hash link and pass that into the plugin. The plugins are basically serverside template components, and these then are responsible for using the url to create a hash link. At least the url generation logic is all in one place, rather than done differently in each plugin.
Well I got the feature working earlier. It was a really tough one to get right. I ran out of build minutes twice, which is why it took so long. But on the flip side, I had the workaround in place, and managed to get it all done with zero downtime on the production site.
The end result is really minimal. Basically it’s just a hash link which looks like # but with a link to the individual post. Every post now has one of these. I also managed to keep the heredocs workaround in place as I turned it into a feature that can be turned on and off easily. I’ll likely test that over the next few days.
All that to say it’s now easy to see where posts start and end via the hash link. A small but very important feature. Glad it’s done. #