middleman-lunr 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a214534d3b05285f6c9aafbeee228de77bf07e4b
4
- data.tar.gz: b733b32a89f7fe3dafc4648fecfd07bdb8686134
3
+ metadata.gz: fab594a7ce40c116fd6e0e7c444ea5937cb194c4
4
+ data.tar.gz: 2aad28f0bae7924142f1703eee600a13ef65af2f
5
5
  SHA512:
6
- metadata.gz: af42f4608d07386b0322a791c1d39f8dc2efe8205c53e9369ac8293744c4a1fd8e5cb03498ebffc1f068dc5fa364eeee38ca0986a6a21c9febad416f41f4d4db
7
- data.tar.gz: aa486320d365eb478d1f21a6aa459f885d0928c6e88b5882508657e4271793ae5d44b9cd9b7e11b66859328a6d311322a1ff0ab9f8f376a9e634126b3080e92b
6
+ metadata.gz: 29da568910eb8d7271206840f83d3954565b3ab9dfd5d46da45c0ee6d9b24ba60ce97ff1f697890cb5abba6585b5134a0b3923e28f8cc9c1d4bcf82fb18d1a0c
7
+ data.tar.gz: a3ac800d4e0d821c8a262ab1364896cf0a6b932575afe8531b8bebf8dd79ec4a009e7b67b31f9abe75376a391742e5f90318637297c6d0650c535c10d6e91a0a
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # middleman-lunr
2
2
 
3
- **middleman extension for static indexed search using lunr.js**
3
+ **middleman extension for a static indexed search using lunr.js**
4
4
 
5
5
  Create a queryable index of your static site content to use with lunr.js.
6
6
 
7
+ A demo can be found at: <https://docs.shiftr.io>.
8
+
7
9
  ## Usage
8
10
 
9
11
  Add gem to your Gemfile:
@@ -12,26 +14,49 @@ Add gem to your Gemfile:
12
14
  gem 'middleman-lunr'
13
15
  ```
14
16
 
15
- Activate the extension:
17
+ Activate the extension in `config.rb`:
16
18
 
17
19
  ```ruby
18
20
  activate :lunr
19
21
  ```
20
22
 
21
- Create a JSON template `search.json.erb` and generate the index:
23
+ Mark the files you wanna index in the [frontmatter](https://middlemanapp.com/basics/frontmatter/):
24
+
25
+ ```
26
+ index: true
27
+ ```
28
+
29
+ Create a JSON template `source/search.json.erb` and generate the index and map:
22
30
 
23
31
  ```html
24
- <%= JSON.generate(generate_search_index) %>
32
+ <%= JSON.generate(generate_search_index({data: [:title, :description]}), max_nesting: false) %>
33
+ ```
34
+ - The generated json will include the lunr.js index under the `index` key and a map that translates lunr.js references to your middleman pages under the `map` key.
35
+ - The `data` argument is an array of [frontmatter](https://middlemanapp.com/basics/frontmatter/) variables that you'd like to include in the map.
36
+
37
+ Reference the lunr.js library in your `layouts/layout.html.erb`:
38
+
39
+ ```html
40
+ <script src="//cdnjs.cloudflare.com/ajax/libs/lunr.js/0.5.9/lunr.min.js" type="text/javascript"></script>
25
41
  ```
26
42
 
27
43
  Load and query the index:
28
44
 
29
45
  ```js
46
+ var index;
47
+ var map;
48
+
30
49
  function loadIndex(){
31
50
  $.getJSON('/search.json', function(data){
32
- var index = lunr.Index.load(data.index);
33
- var map = data.map
34
- console.log(index.search('Lunr.js'));
51
+ index = lunr.Index.load(data.index);
52
+ map = data.map
53
+ });
54
+ }
55
+
56
+ function queryIndex(term) {
57
+ index.search(term).forEach(function(res){
58
+ // use the map to get the page title
59
+ console.log(map[res.ref].title);
35
60
  });
36
61
  }
37
62
  ```
@@ -58,7 +58,7 @@ module Middleman::Lunr
58
58
  idx.add(doc)
59
59
  end
60
60
 
61
- data = JSON.parse(idx.dumpIndex())
61
+ data = JSON.parse(idx.dumpIndex(), max_nesting: false)
62
62
 
63
63
  { index: data, map: map }
64
64
  end
@@ -3,12 +3,12 @@ $:.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.2.0'
6
+ s.version = '0.2.1'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Joël Gähwiler']
9
9
  s.email = ['joel.gaehwiler@gmail.com']
10
10
  s.homepage = 'https://github.com/256dpi/middleman-lunr'
11
- s.summary = 'middleman extension for static indexed search using lunr.js'
11
+ s.summary = 'middleman extension for a static indexed search using lunr.js'
12
12
  s.description = 'Create a queryable index of your static site content to use with lunr.js.'
13
13
  s.license = 'MIT'
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-lunr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joël Gähwiler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman-core
@@ -73,9 +73,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  version: '0'
74
74
  requirements: []
75
75
  rubyforge_project:
76
- rubygems_version: 2.4.5
76
+ rubygems_version: 2.4.5.1
77
77
  signing_key:
78
78
  specification_version: 4
79
- summary: middleman extension for static indexed search using lunr.js
79
+ summary: middleman extension for a static indexed search using lunr.js
80
80
  test_files: []
81
- has_rdoc: