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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 41607c8939aa2383b6fc665af984a3e47cf33eef
4
- data.tar.gz: 02ce98f4deda151fea3d0945914cc8973ceebd0b
3
+ metadata.gz: a214534d3b05285f6c9aafbeee228de77bf07e4b
4
+ data.tar.gz: b733b32a89f7fe3dafc4648fecfd07bdb8686134
5
5
  SHA512:
6
- metadata.gz: 99e177602a6250e7dff9e8551396f64121993b246a693bbcee28c318c8cea079f06ecc37f8e33177b6fcc18982110bf73ac2409f5a2a86ccf46d5ea620b76b59
7
- data.tar.gz: afc17d4d32a05cf8bcdaa5940fd879aa823dcd3f24d89828ce657058e8f31033502c7a4569059f9a63b7a855085cb345180608c5d72e9207a1cdcb18e7b0ce39
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
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'middleman-lunr'
6
- s.version = '0.1.0'
6
+ s.version = '0.2.0'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Joël Gähwiler']
9
9
  s.email = ['joel.gaehwiler@gmail.com']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-lunr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joël Gähwiler