summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-lunr/src
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-09-29 19:04:56 +0200
committerSamy Pesse <samypesse@gmail.com>2016-09-29 19:04:56 +0200
commit9d8dffb6f0aac87c3707a4171140fa66f7e2e82c (patch)
tree7ea5fecc01960b04aa313d85f7ba5ee4d928a638 /packages/gitbook-plugin-lunr/src
parent6015defe11bbdd3bc008cf194e7e88181fe165d0 (diff)
downloadgitbook-9d8dffb6f0aac87c3707a4171140fa66f7e2e82c.zip
gitbook-9d8dffb6f0aac87c3707a4171140fa66f7e2e82c.tar.gz
gitbook-9d8dffb6f0aac87c3707a4171140fa66f7e2e82c.tar.bz2
Fix query action for search
Diffstat (limited to 'packages/gitbook-plugin-lunr/src')
-rw-r--r--packages/gitbook-plugin-lunr/src/index.js21
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
+});