summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-lunr/src/index.js
blob: f1dc913ee7bb18403fc10513aaa161663e967189 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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({
    activate: (dispatch, getState, { Search }) => {
        dispatch(Search.registerHandler('lunr', searchHandler));
    },
    reduce: (state, action) => state
});