From: Vincent Vanwaelscappel Date: Tue, 22 Feb 2022 17:48:05 +0000 (+0100) Subject: wip #5120 @0.25 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f4f040709b579d3b4a4ca0238bd0de02fb431ab6;p=odl.git wip #5120 @0.25 --- diff --git a/resources/js/search.js b/resources/js/search.js index 455e1f8..2b34a30 100644 --- a/resources/js/search.js +++ b/resources/js/search.js @@ -3,7 +3,6 @@ //=====================// import MiniSearch from 'minisearch'; -import {readFile} from 'fs' export default () => ({ @@ -20,13 +19,13 @@ export default () => ({ async init() { // We need the URL from the HTML because it gets properly updated when exporting the final version - readFile(this.$el.dataset.searchindex, function (err, data) { - // Delay miniSearch initialisation so there's less chance of animations stuttering during page loads - setTimeout(() => { - window.minisearch = this.miniSearch = new MiniSearch(); - this.miniSearch.loadJSON(data, this.setup) - }, 4000); - }); + let data = await (await fetch(this.$el.dataset.searchindex)); + + // Delay miniSearch initialisation so there's less chance of animations stuttering during page loads + setTimeout(() => { + window.minisearch = this.miniSearch = new MiniSearch(); + this.miniSearch.loadJSON(data, this.setup) + }, 4000); this.medialibrary = this.$el.dataset.medialibrary; },