2

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.

Christian
  • 4,902
  • 4
  • 24
  • 42
Enderman
  • 21
  • 1
  • (line 176-182), where is this? – KL_KISNE_DEKHA_HAI Mar 07 '21 at 12:29
  • When you go to the example website, in chrome dev tools (F12) you can see the source files, and the JS file there seems to have all the code for the lunr search. Those lines seem to be the index that lunr is supposed to create for searching, but they don't get updated/rebuilt when I change the HTML. – Enderman Mar 07 '21 at 23:30

0 Answers0