diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-10-09 16:52:22 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-10-09 16:52:27 +0200 |
commit | 417013a230dbf19c2e9abaf73d08fe3045024a10 (patch) | |
tree | 93ec66d2ca90daa965f61d2db41882913e99333e /packages/gitbook-plugin-lunr/src | |
parent | 5a57a2c62ad67210143bfe5dd96dd1605b3724f6 (diff) | |
download | gitbook-417013a230dbf19c2e9abaf73d08fe3045024a10.zip gitbook-417013a230dbf19c2e9abaf73d08fe3045024a10.tar.gz gitbook-417013a230dbf19c2e9abaf73d08fe3045024a10.tar.bz2 |
Resolve assets and lunr index before loading
Diffstat (limited to 'packages/gitbook-plugin-lunr/src')
-rw-r--r-- | packages/gitbook-plugin-lunr/src/actions.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/gitbook-plugin-lunr/src/actions.js b/packages/gitbook-plugin-lunr/src/actions.js index 4d878c7..765fa2e 100644 --- a/packages/gitbook-plugin-lunr/src/actions.js +++ b/packages/gitbook-plugin-lunr/src/actions.js @@ -3,6 +3,7 @@ const GitBook = require('gitbook-core'); const TYPES = { LOAD: 'lunr/load' }; +const INDEX_FILENAME = 'search_index.json'; /** * Load an index set @@ -19,7 +20,9 @@ function load(json) { */ function fetch() { return (dispatch, getState) => { - const { idx } = getState().lunr; + const { lunr, file } = getState(); + const { idx } = lunr; + const filePath = file.relative(INDEX_FILENAME); if (idx) { return GitBook.Promise.resolve(); @@ -27,8 +30,7 @@ function fetch() { return GitBook.Promise.resolve() .then(() => { - // TODO: resolve the file correctly - return window.fetch('search_index.json'); + return window.fetch(filePath); }) .then(response => response.json()) .then(json => dispatch(load(json))); |