diff options
Diffstat (limited to 'packages/gitbook-plugin-lunr/src/actions.js')
-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))); |