jekyll-frontmatter-jsonify 0.0.1 → 0.1.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 +14 -4
- data/jekyll-frontmatter-jsonify.gemspec +4 -3
- data/lib/jekyll-frontmatter-jsonify.rb +20 -7
- data/lib/jekyll-frontmatter-jsonify/version.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 722914f5b9e52542944d93bb8137dbbceb414429
|
4
|
+
data.tar.gz: b60daa84c86f9c4eb23247d68442bf307c3e478a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17264ee36f75aed88c5d39f275035157112c60e6663ecda1588c00577d70688126f3011efa55c68fae833fc8caf1df6afd3e626cf2449118088e5640fed1fa93
|
7
|
+
data.tar.gz: f5e3687842dfd0ac075d741cc7336342ec3c8315d3847dc397e4a8ef865e288e76ea984375c9f09f4d14cd721d8fd71c8a321db9fa32085d483894eb3823f12f
|
data/README.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# Jekyll Frontmatter Jsonify
|
2
2
|
|
3
|
-
|
3
|
+
## Use it
|
4
|
+
|
5
|
+
Take a look at [Jekyll's instructions for loading plugins](https://jekyllrb.com/docs/plugins/#installing-a-plugin).
|
6
|
+
|
7
|
+
```
|
8
|
+
gem install jekyll-frontmatter-jsonify
|
9
|
+
```
|
10
|
+
|
11
|
+
## The problem
|
12
|
+
|
13
|
+
The `jsonify` filter when applied to a collection will convert only the body of the collection item into a JSON array, and not the frontmatter.
|
4
14
|
|
5
15
|
For example, we have a collection with two items:
|
6
16
|
|
@@ -24,7 +34,7 @@ food: toast
|
|
24
34
|
Awesome content from 'item2.md'
|
25
35
|
```
|
26
36
|
|
27
|
-
|
37
|
+
### The `jsonify` filter
|
28
38
|
|
29
39
|
```
|
30
40
|
{{ site.sample_collection | jsonify }}
|
@@ -36,7 +46,7 @@ Awesome content from 'item2.md'
|
|
36
46
|
[ "Sample Content from 'item1.md'", "Awesome content from 'item2.md'" ]
|
37
47
|
```
|
38
48
|
|
39
|
-
## The
|
49
|
+
## The solution
|
40
50
|
|
41
51
|
This plug-in introduces the `collection_jsonify` Liquid filter which will convert each collection item's frontmatter into a JSON array.
|
42
52
|
|
@@ -69,4 +79,4 @@ This filter takes a single boolean as a parameter (defaults to `false`) that wil
|
|
69
79
|
|
70
80
|
## License
|
71
81
|
|
72
|
-
MIT
|
82
|
+
MIT
|
@@ -1,12 +1,13 @@
|
|
1
|
+
require File.expand_path '../lib/jekyll-frontmatter-jsonify/version', __FILE__
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.name = 'jekyll-frontmatter-jsonify'
|
3
|
-
s.version =
|
4
|
-
s.date =
|
5
|
+
s.version = Jekyll::FrontMatterJsonify::VERSION
|
6
|
+
s.date = Date.today.to_s
|
5
7
|
s.summary = "Output frontmatter of collections as JSON"
|
6
8
|
s.description = "A liquid filter plugin for Jekyll which outputs the frontmatter of each item in a collection as a JSON array"
|
7
9
|
s.authors = ["City of Santa Monica"]
|
8
10
|
s.email = 'data@smgov.net'
|
9
|
-
s.files = ["lib/jekyll-frontmatter-jsonify.rb"]
|
10
11
|
s.homepage =
|
11
12
|
'https://github.com/CityofSantaMonica/jekyll-frontmatter-jsonify'
|
12
13
|
s.license = 'MIT'
|
@@ -1,22 +1,35 @@
|
|
1
1
|
module Jekyll
|
2
2
|
module FrontMatterJsonify
|
3
|
-
#
|
3
|
+
# Jekyll keys to always ignore
|
4
|
+
KeysBlacklist = [
|
5
|
+
'next', 'previous'
|
6
|
+
]
|
7
|
+
|
8
|
+
# These are keys defined and created by Jekyll. They will be ignored if the user chooses to exclude them from the
|
9
|
+
# JSON array
|
4
10
|
JekyllKeys = [
|
5
|
-
'
|
6
|
-
'
|
11
|
+
'path', 'id', 'output', 'content', 'to_s', 'relative_path',
|
12
|
+
'url', 'collection', 'excerpt', 'draft', 'categories',
|
7
13
|
'title', 'slug', 'ext', 'tags', 'date'
|
8
14
|
]
|
9
15
|
|
10
16
|
def collection_jsonify(collection, ignore_jekyll_keys = false)
|
11
|
-
|
17
|
+
collectionArray = []
|
12
18
|
|
13
19
|
collection.each do |item|
|
14
|
-
|
20
|
+
docDrop = Drops::DocumentDrop.new(item)
|
21
|
+
results = {}
|
22
|
+
|
23
|
+
docDrop.keys.each do |key|
|
24
|
+
next if (ignore_jekyll_keys and JekyllKeys.include? key) or (KeysBlacklist.include? key)
|
25
|
+
|
26
|
+
results[key] = docDrop[key]
|
27
|
+
end
|
15
28
|
|
16
|
-
|
29
|
+
collectionArray << results
|
17
30
|
end
|
18
31
|
|
19
|
-
|
32
|
+
collectionArray.to_json
|
20
33
|
end
|
21
34
|
end
|
22
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-frontmatter-jsonify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- City of Santa Monica
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- README.md
|
36
36
|
- jekyll-frontmatter-jsonify.gemspec
|
37
37
|
- lib/jekyll-frontmatter-jsonify.rb
|
38
|
+
- lib/jekyll-frontmatter-jsonify/version.rb
|
38
39
|
homepage: https://github.com/CityofSantaMonica/jekyll-frontmatter-jsonify
|
39
40
|
licenses:
|
40
41
|
- MIT
|