summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-lunr/src/index.js
blob: eab5975b73b26c3eb57a36284fc249a192f488d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const GitBook = require('gitbook-core');
const reduce = require('./reducer');
const actions = require('./actions');

/**
 * Search in the local index
 * @param  {String} query
 * @return {Promise<List>}
 */
function searchHandler(query, dispatch) {
    return dispatch(actions.fetch())
    .then(() => {
        return [];
    });
}

module.exports = GitBook.createPlugin({
    activate: (dispatch, getState, { Search }) => {
        dispatch(Search.registerHandler('lunr', searchHandler));
    },
    reduce
});