blob: 7e317c4e096e17defa418aecf6e0966ca77d3f8b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
const lunr = require('lunr');
const GitBook = require('gitbook-core');
const { Record } = GitBook.Immutable;
const { TYPES } = require('./actions');
/*
We store the lunr index an the document index in the store.
*/
const LunrState = Record({
idx: null,
store: {}
});
module.exports = GitBook.createReducer('lunr', (state, action) => {
state = state || LunrState();
switch (action.type) {
case TYPES.LOAD:
return state
.set('idx', lunr.Index.load(action.json.index))
.merge({
store: action.json.store
});
default:
return state;
}
});
|