jekyll-frontmatter-jsonify 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: de6168b0fe3028bc633b15dafe93e57f76c44693
4
+ data.tar.gz: c403d1ec5e845f926b32af6fc91000f587ab1666
5
+ SHA512:
6
+ metadata.gz: f5638d7dafa89e17e4554146eac8630f4e9e63e5ec7e4f0e11a96cdcb4a9d3b83d9ef324b200bb54bbc14706f77721adc7d6cc4ebbe6c1a79f5725b244812613
7
+ data.tar.gz: 9df557b37805ecb743c7dcc810e9d52e237a6766019dcd22ece65492b7d0834b44c7e7dadb20892104cb791ddfaa90d62d04dc0cb6a94f81b44ad61d74a1ae02
data/.gitignore ADDED
@@ -0,0 +1,51 @@
1
+ ### Linux ###
2
+ *~
3
+
4
+ # temporary files which can be created if a process still has a handle open of a deleted file
5
+ .fuse_hidden*
6
+
7
+ # KDE directory preferences
8
+ .directory
9
+
10
+ # Linux trash folder which might appear on any partition or disk
11
+ .Trash-*
12
+
13
+
14
+ ### Ruby ###
15
+ *.gem
16
+ *.rbc
17
+ /.config
18
+ /coverage/
19
+ /InstalledFiles
20
+ /pkg/
21
+ /spec/reports/
22
+ /spec/examples.txt
23
+ /test/tmp/
24
+ /test/version_tmp/
25
+ /tmp/
26
+
27
+ ## Specific to RubyMotion:
28
+ .dat*
29
+ .repl_history
30
+ build/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
51
+
data/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # Jekyll Frontmatter Jsonify
2
+
3
+ The problem with the `jsonify` filter on a collection is that it will convert only the body of the collection item into a JSON array but not the frontmatter.
4
+
5
+ For example, we have a collection with two items:
6
+
7
+ **_sample_collection/item1.md**
8
+
9
+ ```
10
+ ---
11
+ food: bacon
12
+ ---
13
+
14
+ Sample Content from 'item1.md'
15
+ ```
16
+
17
+ **_sample_collection/item2.md**
18
+
19
+ ```
20
+ ---
21
+ food: toast
22
+ ---
23
+
24
+ Awesome content from 'item2.md'
25
+ ```
26
+
27
+ ## The `jsonify` filter
28
+
29
+ ```
30
+ {{ site.sample_collection | jsonify }}
31
+ ```
32
+
33
+ **Returns**
34
+
35
+ ```
36
+ [ "Sample Content from 'item1.md'", "Awesome content from 'item2.md'" ]
37
+ ```
38
+
39
+ ## The `collection_jsonify` filter
40
+
41
+ This plug-in introduces the `collection_jsonify` Liquid filter which will convert each collection item's frontmatter into a JSON array.
42
+
43
+ ```
44
+ {{ site.sample_collection | collection_jsonify }}
45
+ ```
46
+
47
+ **Returns**
48
+
49
+ ```
50
+ [
51
+ {
52
+ "food": "bacon",
53
+ // Jekyll default keys
54
+ "draft": false,
55
+ "categories": [],
56
+ "ext": ".md"
57
+ },
58
+ {
59
+ "food": "toast",
60
+ // Jekyll default keys
61
+ "draft": false,
62
+ "categories": [],
63
+ "ext": ".md"
64
+ }
65
+ ]
66
+ ```
67
+
68
+ This filter takes a single boolean as a parameter (defaults to `false`) that will ignore Jekyll's default keys in the frontmatter and only return the custom data a collection item has in its frontmatter. In the above example, only the "food" key would be outputted if the parameter was set to true (i.e. ` | collection_jsonify: true`)
69
+
70
+ ## License
71
+
72
+ MIT
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'jekyll-frontmatter-jsonify'
3
+ s.version = '0.0.1'
4
+ s.date = '2016-05-18'
5
+ s.summary = "Output frontmatter of collections as JSON"
6
+ s.description = "A liquid filter plugin for Jekyll which outputs the frontmatter of each item in a collection as a JSON array"
7
+ s.authors = ["City of Santa Monica"]
8
+ s.email = 'data@smgov.net'
9
+ s.files = ["lib/jekyll-frontmatter-jsonify.rb"]
10
+ s.homepage =
11
+ 'https://github.com/CityofSantaMonica/jekyll-frontmatter-jsonify'
12
+ s.license = 'MIT'
13
+
14
+ s.files = `git ls-files -z`.split("\x0")
15
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
+ s.require_paths = ["lib"]
17
+
18
+ s.add_dependency "jekyll", '>= 2.4'
19
+ end
@@ -0,0 +1,24 @@
1
+ module Jekyll
2
+ module FrontMatterJsonify
3
+ # These are keys defined by Jekyll that don't mean anything to analytics-reporter
4
+ JekyllKeys = [
5
+ 'next', 'previous', 'path', 'id', 'output', 'content', 'to_s',
6
+ 'relative_path', 'url', 'collection', 'excerpt', 'draft', 'categories',
7
+ 'title', 'slug', 'ext', 'tags', 'date'
8
+ ]
9
+
10
+ def collection_jsonify(collection, ignore_jekyll_keys = false)
11
+ results = []
12
+
13
+ collection.each do |item|
14
+ JekyllKeys.each{ |k| item.data.delete(k) } if ignore_jekyll_keys
15
+
16
+ results << item.data
17
+ end
18
+
19
+ results.to_json
20
+ end
21
+ end
22
+ end
23
+
24
+ Liquid::Template.register_filter(Jekyll::FrontMatterJsonify)
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-frontmatter-jsonify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - City of Santa Monica
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ description: A liquid filter plugin for Jekyll which outputs the frontmatter of each
28
+ item in a collection as a JSON array
29
+ email: data@smgov.net
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - README.md
36
+ - jekyll-frontmatter-jsonify.gemspec
37
+ - lib/jekyll-frontmatter-jsonify.rb
38
+ homepage: https://github.com/CityofSantaMonica/jekyll-frontmatter-jsonify
39
+ licenses:
40
+ - MIT
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 2.4.5.1
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: Output frontmatter of collections as JSON
62
+ test_files: []