Remove duplication when aggregating post information

This commit is contained in:
Matt Rogers
2013-03-05 19:11:07 -06:00
parent 2dd98816d4
commit 6399ec9b2b

View File

@@ -195,9 +195,7 @@ module Jekyll
post = Post.new(self, self.source, dir, f)
if post.published && (self.future || post.date <= self.time)
self.posts << post
post.categories.each { |c| self.categories[c] << post }
post.tags.each { |c| self.tags[c] << post }
aggregate_post_info(post)
end
end
end
@@ -217,9 +215,7 @@ module Jekyll
if Draft.valid?(f)
draft = Draft.new(self, self.source, dir, f)
self.posts << draft
draft.categories.each { |c| self.categories[c] << draft }
draft.tags.each { |c| self.tags[c] << draft }
aggregate_post_info(draft)
end
end
end
@@ -403,5 +399,16 @@ module Jekyll
return [] unless File.exists?(base)
entries = Dir.chdir(base) { filter_entries(Dir['**/*']) }
end
# Aggregate post information
#
# post - The Post object to aggregate information for
#
# Returns nothing
def aggregate_post_info(post)
self.posts << post
post.categories.each { |c| self.categories[c] << post }
post.tags.each { |c| self.tags[c] << post }
end
end
end