From f4f040709b579d3b4a4ca0238bd0de02fb431ab6 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 22 Feb 2022 18:48:05 +0100 Subject: [PATCH] wip #5120 @0.25 --- resources/js/search.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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; }, -- 2.39.5