A few months ago, someone opened an issue asking for a site search on my blog. Neat idea, it wasn’t high on my list of priorities at the time, but maybe I’d get to it someday.
Well, today’s the day 🎉
(Note: The original “the day” was two weeks ago but I had given up in frustration.)
Search is an interesting problem. Most search engines run on servers and not the browser client. This site, just like all static sites like those built with Middleman, is generated on a computer before being served statically. It’s a faster, easier, and more secure way of serving web pages that don’t need dynamism, but it does mean that you can’t run server code when a page is fetched.
A bit like Solr, but much smaller and not as bright.
Lovely. I think the sun-vs-moon metaphor for server-vs-client search engines is really apt.
I submitted a work-in-progress pull request and gave up again.
Some fiddling with CSS and lining things up, I had a ready PR.
After submitting the pull request, I realized I had been working into the late evening, that I’d had a beer or two, and that maybe pushing code to production wasn’t the best thing to do. I pinged Orta on the pull request and asked for a second opinion. It can never hurt to have someone double-check things for you.
Things checked out, and search is here.
The pull request is here, so feel free to comment on anything that you’d like clarification on or that you have a suggestion about. I’m sure there are ways this could be more idiomatically done. (Update: I’ve added documentation to all the code and linked to the relevant code in the readme.)
Writing new features into software can be overwhelming, and stepping back for a break is usually the right answer. It’s okay to give up if things are getting frustrating, and it’s okay to ask for help.
PARTY TIP: At the end of the day, just try your hardest to be nice.— ANDREW W.K. (@AndrewWK) April 20, 2016
We’re all in this together.