jekyll-archives 2.0.0 → 2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll-archives.rb +17 -27
  3. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48e56741682593af17480d365d5de16375c37729
4
- data.tar.gz: ea83b0b10d88f06accac63377b8dfeed11c66b6d
3
+ metadata.gz: 5a8ef4604c09a50287db80e71c8846c6aea627f6
4
+ data.tar.gz: 7fcde0b456187ed2d2aecdc1fbf77b422fad5b71
5
5
  SHA512:
6
- metadata.gz: 0b2e0ac8335e6da021502b1360e9ce3ac26787f8f692b9933e19de2533b0c9bb65a6493927e89c5ce75523555dd8f1b5d6bb6aca7c8b32e8a626beafd835b621
7
- data.tar.gz: 377989415b51fb0d5251141a5367bcd54fa89ca4472bfd95ccbba0e775edcc5a67cf81a916fd9121431d09982edc2eaaa67146016e4770b06df45f8dd89bde65
6
+ metadata.gz: c82973bc0333cb8e17784c13406333c8216439128688e599cc943b8b526db6bc2f38793545bc8f585330771a6a1b1ef1d55f7b4d62907aa85698a28db94a8dfa
7
+ data.tar.gz: 0026bfd635bb6b318003f552524f872cc783e20dd4658ee463f8dbd654a761a980a86cfd9d9e3a36b273019e13cbdde1e39be4bb907f8f8bf89258b4694edc63
@@ -6,6 +6,14 @@ module Jekyll
6
6
  autoload :Archive, 'jekyll-archives/archive'
7
7
  autoload :VERSION, 'jekyll-archives/version'
8
8
 
9
+ if (Jekyll.const_defined? :Hooks)
10
+ Jekyll::Hooks.register :site, :after_reset do |site|
11
+ # We need to disable incremental regen for Archives to generate with the
12
+ # correct content
13
+ site.regenerator.instance_variable_set(:@disabled, true)
14
+ end
15
+ end
16
+
9
17
  class Archives < Jekyll::Generator
10
18
  safe true
11
19
 
@@ -104,42 +112,24 @@ module Jekyll
104
112
  end
105
113
  end
106
114
 
107
- # Construct a Hash of Posts indexed by the specified Post attribute.
108
- #
109
- # post_attr - The String name of the Post attribute.
110
- #
111
- # Examples
112
- #
113
- # post_attr_hash('categories')
114
- # # => { 'tech' => [<Post A>, <Post B>],
115
- # # 'ruby' => [<Post B>] }
116
- #
117
- # Returns the Hash: { attr => posts } where
118
- # attr - One of the values for the requested attribute.
119
- # posts - The Array of Posts with the given attr value.
120
- #
121
- # Taken from jekyll/jekyll (Copyright (c) 2014 Tom Preston-Werner under the MIT).
122
- def post_attr_hash(post_attr)
123
- # Build a hash map based on the specified post attribute ( post attr =>
124
- # array of posts ) then sort each array in reverse order.
125
- hash = Hash.new { |h, key| h[key] = [] }
126
- @posts.each { |p| p.send(post_attr.to_sym).each { |t| hash[t] << p } }
127
- hash.values.each { |posts| posts.sort!.reverse! }
128
- hash
129
- end
130
-
131
115
  def tags
132
- post_attr_hash('tags')
116
+ @site.post_attr_hash('tags')
133
117
  end
134
118
 
135
119
  def categories
136
- post_attr_hash('categories')
120
+ @site.post_attr_hash('categories')
137
121
  end
138
122
 
139
123
  # Custom `post_attr_hash` method for years
140
124
  def years
141
125
  hash = Hash.new { |h, key| h[key] = [] }
142
- @posts.each { |p| hash[p.date.strftime("%Y")] << p }
126
+
127
+ # In Jekyll 3, Collection#each should be called on the #docs array directly.
128
+ if Jekyll::VERSION >= '3.0.0'
129
+ @posts.docs.each { |p| hash[p.date.strftime("%Y")] << p }
130
+ else
131
+ @posts.each { |p| hash[p.date.strftime("%Y")] << p }
132
+ end
143
133
  hash.values.each { |posts| posts.sort!.reverse! }
144
134
  hash
145
135
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-archives
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alfred Xing
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '2.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.4.5
111
+ rubygems_version: 2.4.5.1
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Post archives for Jekyll.