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.
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
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);
|
|
|
|
const router = new Router({
|
|
mode: 'history',
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
component: () => import(/* webpackChunkName: "Home" */ './pages/Home.vue'),
|
|
children: [
|
|
{
|
|
path: '',
|
|
name: 'search',
|
|
component: () => import(/* webpackChunkName: "Search" */ './pages/Search.vue'),
|
|
},
|
|
{
|
|
path: 'favorites',
|
|
name: 'favorites',
|
|
component: () => import(/* webpackChunkName: "Favorites" */ './pages/Favorites.vue'),
|
|
},
|
|
],
|
|
},
|
|
],
|
|
});
|
|
|
|
const app = new Vue({
|
|
router,
|
|
render: h => h('div', { attrs: { id: 'app' } }, [h('router-view')]),
|
|
});
|
|
|
|
export default app;
|