From dda0a0eab19457598b71f2b2b2f978b09d3f95c7 Mon Sep 17 00:00:00 2001 From: Alex Shpak Date: Mon, 15 Jul 2019 18:25:21 +0200 Subject: Start work on search feature with lunr --- .../assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content | 6 ++++++ .../_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json | 1 + 2 files changed, 7 insertions(+) create mode 100644 exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content create mode 100644 exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json (limited to 'exampleSite/resources/_gen/assets/js') diff --git a/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content b/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content new file mode 100644 index 0000000..9c34794 --- /dev/null +++ b/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.content @@ -0,0 +1,6 @@ +addEventListener("load",function(){let input=document.querySelector("#book-search");let results=document.querySelector("#book-search-results");Promise.all([loadScript("/example/lunr.min.js"),loadScript("/example/index.json")]).then(enableLunr);function enableLunr(){results.idx=lunr(function(){this.ref('href') +this.field('title') +this.field('content') +window.lunrData.forEach(function(page){this.add(page)},this)});input.addEventListener("keyup",search);} +function search(){if(input.value){var hits=results.idx.search(`${input.value}*`);results.innerHTML=JSON.stringify(hits);}else{results.innerHTML='';}} +function loadScript(src){return new Promise(function(resolve,reject){let script=document.createElement('script');script.src=src;script.onload=()=>resolve(script);document.head.append(script);});}}); \ No newline at end of file diff --git a/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json b/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json new file mode 100644 index 0000000..0c68ef7 --- /dev/null +++ b/exampleSite/resources/_gen/assets/js/search.js_db9e329433ffca0798ed12c88043b3b3.json @@ -0,0 +1 @@ +{"Target":"search.min.f37565c4baa28364f7b8e1e53c35bdb0ab92f2215165bd3f083f3f4f1ae78c71.js","MediaType":"application/javascript","Data":{"Integrity":"sha256-83VlxLqig2T3uOHlPDW9sKuS8iFRZb0/CD8/TxrnjHE="}} \ No newline at end of file -- cgit v1.2.3