@@ -112,42 +112,12 @@ def write
112112 end
113113 end
114114
115- # Construct a Hash of Posts indexed by the specified Post attribute.
116- #
117- # post_attr - The String name of the Post attribute.
118- #
119- # Examples
120- #
121- # post_attr_hash('categories')
122- # # => { 'tech' => [<Post A>, <Post B>],
123- # # 'ruby' => [<Post B>] }
124- #
125- # Returns the Hash: { attr => posts } where
126- # attr - One of the values for the requested attribute.
127- # posts - The Array of Posts with the given attr value.
128- #
129- # Taken from jekyll/jekyll (Copyright (c) 2014 Tom Preston-Werner under the MIT).
130- def post_attr_hash ( post_attr )
131- # Build a hash map based on the specified post attribute ( post attr =>
132- # array of posts ) then sort each array in reverse order.
133- hash = Hash . new { |h , key | h [ key ] = [ ] }
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
141- hash . values . each { |posts | posts . sort! . reverse! }
142- hash
143- end
144-
145115 def tags
146- post_attr_hash ( 'tags' )
116+ @site . post_attr_hash ( 'tags' )
147117 end
148118
149119 def categories
150- post_attr_hash ( 'categories' )
120+ @site . post_attr_hash ( 'categories' )
151121 end
152122
153123 # Custom `post_attr_hash` method for years
0 commit comments