Search functionality#11
Conversation
|
One thing I will say is that while working on this it did sorta strike me that this style of search functionality might be better handled with a dedicated npm package since handling a lot of the edge cases of searching is non-trivial. Depends what your future long term goals are with this site; just trying to make sure that things are easy to iterate on/ maintain in the future . |
|
A dependency on an NPM package would not be ideal. This is meant to basically be a static site. Is it possible to index on a new page? Personally pop-up search is totally overrated and I don't mind being directed to a new page for results. |
|
Sure, whatever you prefer. Just wanted to call that out as an option. I tried implementing the result outputs on a separate page, which I think is a good and reasonable idea, but I couldn't get it working. I don't know how to get the hugo template to render /search. Created a separate PR in #12 which anyone can feel free to edit or take code from. |
|
Yeah Hugo is a PITA sometimes. Not as untuitive as other SSGs. Will take a look this evening. |
|
Sounds good. No rush on this at all. Just trying to make something helpful for others. Wrote up a little description of the challenge in #12 i presume it is something simple since im not too familiar with hugo |
This PR adds search functionality. It does this by statically generating an index JSON file when
hugois ran. The search bar then can use a regex to search through it.It is a naive search algorithm but it is better than nothing and helps to search for keywords. I adapted the code from https://decovar.dev/blog/2020/01/05/hugo-search/ I put the source at the top of the js file
I am a bit stuck on getting the accessibility working. Orca at least reads out the last search result. Not sure if that is sufficient or what the best practices are.
Also made a minor change in the date for one blog post that incorrectly formatted and prevented builds. Also added a gitignore