Live Hugo Site search with Lunr.js

Hi @rdwatters
Thanks for taking time to write this up. I really appreciate it.
I believe there is a tiny error in the code, namely in “$index 1”:

{{ if and $index (gt $index 1) }},{{ end }}

I believe this causes the first comma between blocks to be missing in JSON file (try running your JSON file through JSONLint). I found when the above line is updated to the following, no commas are missing (and json-minify npm library accepts it):

{{ if and $index (gt $index 0) }},{{ end }}

I’m trying to use your way of generating Lunr.js index file via Hugo because I’m having trouble with hugo-lunr library.

I’m currently in the middle of integrating npm scripts, Hugo and Lunr.js. Here’s an excerpt from my package.json — the Lunr site index /public/json/index.html is being minified and saved into Hugo root directory:

"scripts": {
...
"index:prepare": "json-minify public/json/index.html > public/site-index.json",
...
}

Again, thanks for sharing!
Roy