I recently started a web project where I have to implement a search button for searching on my website, but client-side. So I found lunr.js
. My problem is.. how do I index the pages? Yeah, I do know the drill written on their site.. though, it is not clear enough.. where do I implement that script?? ( see below ) What do I use??
var index = lunr(function () {
this.field('title', {boost: 10})
this.field('body')
this.ref('id')
})
index.add({
id: 1,
title: 'Foo',
body: 'Foo foo foo!'
})
index.add({
id: 2,
title: 'Bar',
body: 'Bar bar bar!'
})
Where do I put this code? I have clearly no idea.