chore: add data and lunr via plugins

this way lunr is only set up once, which speeds up the loading of the search page. also makes sure the data doesn't increadse the bundle sizes of the various pages that use it.
This commit is contained in:
2018-09-17 18:09:42 -07:00
parent 3154b1e014
commit 8c45a533b0
5 changed files with 53 additions and 17 deletions

View File

@@ -1,6 +1,23 @@
import Vue from 'vue';
import Router from 'vue-router';
import './filters.mjs';
import strainData from './plugins/strainData.mjs';
import lunr from './plugins/lunr.mjs';
Vue.use(strainData);
Vue.use(
lunr(function lunrSetup() {
// lunr search index setup
this.ref('id');
this.field('name');
this.field('effects');
this.field('uses');
this.field('conditions');
this.field('flavors');
Vue.prototype.$strainData.strains.forEach(doc => this.add(doc));
})
);
Vue.use(Router);