From 8c45a533b0a46660db64e7146a4932d60b492c84 Mon Sep 17 00:00:00 2001 From: joe fleming Date: Mon, 17 Sep 2018 18:09:42 -0700 Subject: [PATCH] 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. --- packages/search-site/src/index.mjs | 17 ++++++++++ packages/search-site/src/pages/Favorites.vue | 4 +-- packages/search-site/src/pages/Search.vue | 31 ++++++++++--------- packages/search-site/src/plugins/lunr.mjs | 10 ++++++ .../search-site/src/plugins/strainData.mjs | 8 +++++ 5 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 packages/search-site/src/plugins/lunr.mjs create mode 100644 packages/search-site/src/plugins/strainData.mjs diff --git a/packages/search-site/src/index.mjs b/packages/search-site/src/index.mjs index 60c8184..34a432d 100644 --- a/packages/search-site/src/index.mjs +++ b/packages/search-site/src/index.mjs @@ -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); diff --git a/packages/search-site/src/pages/Favorites.vue b/packages/search-site/src/pages/Favorites.vue index 3f65a6b..d3a3aa1 100644 --- a/packages/search-site/src/pages/Favorites.vue +++ b/packages/search-site/src/pages/Favorites.vue @@ -19,7 +19,6 @@