Last year (sometimes that surprises me, time has been so weird with COVID) I wrote about using Algolia with Eleventy, and specifically how I added it here (Adding Algolia Search to Eleventy and Netlify - Part Two). A few weeks ago I discovered an issue with my implementation that caused the index on Algolia's side to be empty. I fixed that issue and updated my blog post with a detailed description on top. Everything was perfect.
A few days ago I posted ("Using Lunr with Eleventy via Netlify Serverless Functions") about how you could use Lunr via serverless functions. The thinking was that it would help make Lunr more useful for large content sites. In a "typical" Lunr example, you load your data and client all in the browser, which means indexing a lot of content wouldn't be very effecient. That post demonstrated that you absolutely could run Lunr in a serverless function, but it bothered me that the index was being recreated on every search.
Lunr is a great client-side search engine that works really well with the Jamstack. (Be sure to see my earlier posts on the topic: Adding Search to your Eleventy Static Site with Lunr, Integrating Navigation Search with Lunr and Eleventy, and Using Pre-Built Lunr Indexes with Eleventy) While I like the simplicity of Lunr, it requires that your searched data be loaded on the client-side. This makes it a bad fit for large sites. For example, my blog has over six thousand posts so I went Algolia instead. However, I was doing some thinking recently and realized that Lunr can also be used on the server as well. I decided to take a stab at trying this out and here's what I came up with.
I try to exercise every week day (although with today being a holiday I gave myself a pass). In order to make the exercise a bit more palatable, I'll watch a good show while I'm exercising. The best shows are those that are an hour long on TV since they are typically right at forty-five minutes with commercials removed. Forty-five minutes is my target workout length so that works out great. Currently I'm rewatching "Breaking Bad", an incredibly good show I've watched before but am enjoying all over again.
Since this just bit me in the butt - for the second time - I figured I'd do a real quick blog post. This isn't to help me remember, but to ensure it comes up next time I google for it.
Growing up (a long, long time ago), I was a huge fan of the "Choose Your Own Advenure" line of books. These books all followed a basic idea. You would begin reading and quickly be given a choice. If you pick one option, you turn to a page, if you pick another you go there. You could typically do an entire read through quickly an then just back in and make different choices. There were a huge amount of these published and they were known for having some pretty bizzare subjects. One even included a path that was impossible to reach unless you cheated. (And yes, I remember doing exactly that.) These books were pretty popular years ago and in fact led to folks building maps for the story lines and the various paths.
Before I begin, a quick note. While what I've built seems to be working ok, I'm still tweaking things a bit so please forgive me if anything doesn't work exactly right. Be sure to reach out and let me know if you run into any issues. Alright, so the topic of this post is how you can incorporate an email subscription service into your Jamstack site, specifically a blog. While most blogs, including mine, offer an RSS feed, I've not been a big user of RSS readers myself. I like the idea, it just hasn't worked well for me as I forget to run them, fall behind and then feel like it's a chore to go through my various subscriptions. Instead, I prefer signing up for an email when a new post is released. Not every blog has that service and in cases like that I've used services like IFTTT to create my own subscription. I decided to take a look into what it would take to add such a service to my own blog.
When I don't blog on a regular cadence (once a week), I start to whig out a bit, and despite the absolute huge amount of content here (notice I didn't say good content), I begin to stress out when I don't meet that self-imposed schedule. On a whim, I decided to work on something that's been in my queue for a while but realized that in order for that post to be done, I needed some recent content on the blog.
For a large portion of my development career, I've been a databaser user of some sort or another. I spent many years working with app servers (ColdFusion) and almost always they were tied to a SQL database of some sort. In the beginning this was Microsoft Access (it was really easy to use), then SQL Server and eventually MySQL. Most recently I've made more use of NoSQL databases, like Mongo and Fauna. While I definitely prefer NoSQL databases, after years of using SQL, I still have a bit of fondness for it. It's with this in mind that I decided to look into integrating MySQL with Eleventy. Over the weekend I built a quick demo and was planning on blogging sometime this week, but was inspired to get this out sooner when I saw this cool Tweet: