I have been trying unsuccessfully to make an offline HTML FAQ page that searches for answers in a JSON document, however, I cannot figure out how to get it working.
The main thing I tried is downloading the HTML and JS from the lunr example on the website https://olivernn.github.io/moonwalkers/
The problem seems to be that the text and index are hard-coded into the JS document (lines 176-182), so even when I edit the text in the HTML file it just resets to the original text when I click search. It does not rebuild the index.
My questions:
- How can I modify the HTML and/or JS file to rebuild the index after I change the HTML?
- Why is there just an index.js file instead of a separate lunr.js and then index.js just for the indexed data?
- How can I change it so that it reads a separate JSON file with the data?
P.S.
If getting the example on the website working is too difficult (it looks very complex), can someone please show me a working barebones lunr search?
Just a super simple HTML text box with a button that builds an index from a JSON file and displays the results. If I can see a working example I think I can figure it out from there.