middleman-lunr 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/middleman-lunr/indexer.rb +8 -1
- data/middleman-lunr.js.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a214534d3b05285f6c9aafbeee228de77bf07e4b
|
4
|
+
data.tar.gz: b733b32a89f7fe3dafc4648fecfd07bdb8686134
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af42f4608d07386b0322a791c1d39f8dc2efe8205c53e9369ac8293744c4a1fd8e5cb03498ebffc1f068dc5fa364eeee38ca0986a6a21c9febad416f41f4d4db
|
7
|
+
data.tar.gz: aa486320d365eb478d1f21a6aa459f885d0928c6e88b5882508657e4271793ae5d44b9cd9b7e11b66859328a6d311322a1ff0ab9f8f376a9e634126b3080e92b
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ activate :lunr
|
|
21
21
|
Create a JSON template `search.json.erb` and generate the index:
|
22
22
|
|
23
23
|
```html
|
24
|
-
<%= generate_search_index %>
|
24
|
+
<%= JSON.generate(generate_search_index) %>
|
25
25
|
```
|
26
26
|
|
27
27
|
Load and query the index:
|
@@ -29,7 +29,8 @@ Load and query the index:
|
|
29
29
|
```js
|
30
30
|
function loadIndex(){
|
31
31
|
$.getJSON('/search.json', function(data){
|
32
|
-
var index = lunr.Index.load(data);
|
32
|
+
var index = lunr.Index.load(data.index);
|
33
|
+
var map = data.map
|
33
34
|
console.log(index.search('Lunr.js'));
|
34
35
|
});
|
35
36
|
}
|
@@ -10,6 +10,7 @@ module Middleman::Lunr
|
|
10
10
|
def generate(options)
|
11
11
|
docs = []
|
12
12
|
fields = []
|
13
|
+
map = {}
|
13
14
|
|
14
15
|
if options[:body]
|
15
16
|
fields.push(:body)
|
@@ -22,6 +23,8 @@ module Middleman::Lunr
|
|
22
23
|
@extension.sitemap.resources.each do |res|
|
23
24
|
if res.data[:index]
|
24
25
|
doc = { id: res.url.to_s }
|
26
|
+
key = res.url.to_s
|
27
|
+
data = {}
|
25
28
|
|
26
29
|
if options[:body]
|
27
30
|
doc[:body] = File.read(res.source_file)
|
@@ -29,9 +32,11 @@ module Middleman::Lunr
|
|
29
32
|
|
30
33
|
options[:data].each do |d|
|
31
34
|
doc[d] = res.data[d]
|
35
|
+
data[d.to_s] = res.data[d]
|
32
36
|
end
|
33
37
|
|
34
38
|
docs << doc
|
39
|
+
map[key] = data
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
@@ -53,7 +58,9 @@ module Middleman::Lunr
|
|
53
58
|
idx.add(doc)
|
54
59
|
end
|
55
60
|
|
56
|
-
idx.dumpIndex()
|
61
|
+
data = JSON.parse(idx.dumpIndex())
|
62
|
+
|
63
|
+
{ index: data, map: map }
|
57
64
|
end
|
58
65
|
end
|
59
66
|
end
|
data/middleman-lunr.js.gemspec
CHANGED