//=====================//
import MiniSearch from 'minisearch';
-import {readFile} from 'fs'
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;
},