diff options
Diffstat (limited to 'packages/gitbook-plugin-lunr/src/index.js')
-rw-r--r-- | packages/gitbook-plugin-lunr/src/index.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/packages/gitbook-plugin-lunr/src/index.js b/packages/gitbook-plugin-lunr/src/index.js new file mode 100644 index 0000000..16caf96 --- /dev/null +++ b/packages/gitbook-plugin-lunr/src/index.js @@ -0,0 +1,21 @@ +const GitBook = require('gitbook-core'); +const lunr = require('lunr'); + +/** + * Search in the local index + * @param {String} query + * @return {Promise<List>} + */ +function searchHandler(query) { + return [ + { title: 'Hello world' } + ]; +} + +module.exports = GitBook.createPlugin({ + init: (dispatch, getState, actions) => { + const { search } = actions; + dispatch(search.registerHandler('lunr', searchHandler)); + }, + reduce: (state, action) => state +}); |