middleman-lunr 0.2.0 → 0.2.1
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 +32 -7
- data/lib/middleman-lunr/indexer.rb +1 -1
- data/middleman-lunr.js.gemspec +2 -2
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fab594a7ce40c116fd6e0e7c444ea5937cb194c4
|
4
|
+
data.tar.gz: 2aad28f0bae7924142f1703eee600a13ef65af2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
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
|
```
|
data/middleman-lunr.js.gemspec
CHANGED
@@ -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.
|
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.
|
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-
|
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:
|