I’ve mentioned before this is a static site so how is it there’s now a search function. The magic of javascript!
I’d seen a search box on hugo sites so I looked around and found these two articles 1 2 on adding search and they each built on each other using lunr.
I tweaked the index building to try and squash it down a bit. The
javascript I use to build the lunr prebuilt indexes
(search/index.json
and search/results.json
) is currently as follows:
|
|
The uniq
bit, which came up yesterday in shell, did shrink down
the index files, but they’re still pretty large. However in reading the
lunr docs the win in pre-built indexes is that it reduces computation. In
addition lunr has a pipeline system where work should be
done to index the files.
So I suspect in future iterations I’ll be removing the uniq function and instead using lunr’s pipeline system to filter and fine tune the words being indexed.