UNPKG

711 BJavaScriptView Raw
1// Generated by CoffeeScript 1.12.7
2(function() {
3 var index, lunr;
4
5 lunr = require('lunr');
6
7 index = null;
8
9 exports.loadIndex = function(config) {
10 var indexDump;
11 indexDump = require(config.buildLunrIndex);
12 return index = {
13 lunr: lunr.Index.load(indexDump.idx),
14 docs: indexDump.docsIdx
15 };
16 };
17
18 exports.search = function(searchTerm) {
19 if (index == null) {
20 throw new Error('Doxx: Lunr index must be loaded before using search.');
21 }
22 return index.lunr.search(searchTerm).map(function(result) {
23 var ref;
24 ref = result.ref;
25 return {
26 id: ref,
27 title: index.docs[ref],
28 link: '/' + ref
29 };
30 });
31 };
32
33}).call(this);