jekyll-itafroma-post_groups 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 +7 -0
- data/lib/jekyll/itafroma/post_groups.rb +45 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: b1a153bc02428b4d1050de9f9b61f8c3afaf5e0e
|
|
4
|
+
data.tar.gz: 61f737a79e7adf9f64246225969bc4b836cacf7c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 952b67bd8a15d25de8decfba31523267e54cf43239ebe09925149d83e570951c1888401ed94dc29bd45d5c2f515b72a490d85c27f8ed51487b005491763e2014
|
|
7
|
+
data.tar.gz: 9cbfdcd3131ac9b2a05fbb59134c541a8ec3d592aa0b58da9277abc62a304355761aca7852fed2fb0af7458656aa24536b7374fc9429ca0c08a8a701a3a7e15a
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Creates site variables that group posts by arbitrary front-matter keys.
|
|
3
|
+
#
|
|
4
|
+
# Author:: Mark Trapp
|
|
5
|
+
# Copyright: Copyright (c) 2014 Mark Trapp
|
|
6
|
+
# License:: MIT
|
|
7
|
+
|
|
8
|
+
module Jekyll
|
|
9
|
+
module Itafroma
|
|
10
|
+
class PostGroupsGenerator < Jekyll::Generator
|
|
11
|
+
def generate(site)
|
|
12
|
+
site.config['post_groups'].each do |group|
|
|
13
|
+
key = group['key']
|
|
14
|
+
key_plural = group['key_plural'] || group['key']
|
|
15
|
+
exclude = group['exclude'] || []
|
|
16
|
+
site.config[key_plural] = post_key_hash(site, key, exclude)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
##
|
|
21
|
+
# Generates a hash using a key from a post's front-matter.
|
|
22
|
+
#
|
|
23
|
+
def post_key_hash(site, post_key, exclude)
|
|
24
|
+
# Build a hash map based on the specified post attribute ( post attr =>
|
|
25
|
+
# array of posts ) then sort each array in reverse order.
|
|
26
|
+
hash = Hash.new { |hsh, key| hsh[key] = Array.new }
|
|
27
|
+
site.posts.each do |p|
|
|
28
|
+
# Skip post if it doesn't have the correct key
|
|
29
|
+
next unless p.data.key? post_key
|
|
30
|
+
|
|
31
|
+
# Load the value for the key and check if it should be excluded
|
|
32
|
+
t = p.data.fetch(post_key)
|
|
33
|
+
next if exclude.include? t
|
|
34
|
+
|
|
35
|
+
# Add the post to the hash
|
|
36
|
+
hash[t] << p
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Sort the hash
|
|
40
|
+
hash.values.map { |sortme| sortme.sort! { |a, b| b <=> a } }
|
|
41
|
+
hash
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: jekyll-itafroma-post_groups
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Mark Trapp
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Jekyll plugin to group posts by arbitrary front-matter keys.
|
|
14
|
+
email: mark@marktrapp.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/jekyll/itafroma/post_groups.rb
|
|
20
|
+
homepage: http://marktrapp.com/projects/jekyll-post-groups
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubyforge_project:
|
|
40
|
+
rubygems_version: 2.0.6
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Jekyll plugin to group posts by arbitrary front-matter keys.
|
|
44
|
+
test_files: []
|