File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,13 @@ def post_attr_hash(post_attr)
131131 # Build a hash map based on the specified post attribute ( post attr =>
132132 # array of posts ) then sort each array in reverse order.
133133 hash = Hash . new { |h , key | h [ key ] = [ ] }
134- @posts . docs . each { |p | p . data [ post_attr ] . each { |t | hash [ t ] << p } }
134+
135+ # In Jekyll 3, Collection#each should be called on the #docs array directly.
136+ if defined? @posts . docs
137+ @posts . docs . each { |p | p . data [ post_attr ] . each { |t | hash [ t ] << p } }
138+ else
139+ @posts . each { |p | p . send ( post_attr . to_sym ) . each { |t | hash [ t ] << p } }
140+ end
135141 hash . values . each { |posts | posts . sort! . reverse! }
136142 hash
137143 end
@@ -147,7 +153,13 @@ def categories
147153 # Custom `post_attr_hash` method for years
148154 def years
149155 hash = Hash . new { |h , key | h [ key ] = [ ] }
150- @posts . docs . each { |p | hash [ p . date . strftime ( "%Y" ) ] << p }
156+
157+ # In Jekyll 3, Collection#each should be called on the #docs array directly.
158+ if defined? @posts . docs
159+ @posts . docs . each { |p | hash [ p . date . strftime ( "%Y" ) ] << p }
160+ else
161+ @posts . each { |p | hash [ p . date . strftime ( "%Y" ) ] << p }
162+ end
151163 hash . values . each { |posts | posts . sort! . reverse! }
152164 hash
153165 end
You can’t perform that action at this time.
0 commit comments