]> _ Git - odl.git/commitdiff
wip #5120 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 22 Feb 2022 17:48:05 +0000 (18:48 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 22 Feb 2022 17:48:05 +0000 (18:48 +0100)
resources/js/search.js

index 455e1f85e40aa05b170b0f7a35bb28622828f406..2b34a3008a1b2c78efc146ca0fd7fb23458852c2 100644 (file)
@@ -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;
     },