Remove duplication when aggregating post information
This commit is contained in:
parent
2dd98816d4
commit
6399ec9b2b
|
@ -195,9 +195,7 @@ module Jekyll
|
||||||
post = Post.new(self, self.source, dir, f)
|
post = Post.new(self, self.source, dir, f)
|
||||||
|
|
||||||
if post.published && (self.future || post.date <= self.time)
|
if post.published && (self.future || post.date <= self.time)
|
||||||
self.posts << post
|
aggregate_post_info(post)
|
||||||
post.categories.each { |c| self.categories[c] << post }
|
|
||||||
post.tags.each { |c| self.tags[c] << post }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -217,9 +215,7 @@ module Jekyll
|
||||||
if Draft.valid?(f)
|
if Draft.valid?(f)
|
||||||
draft = Draft.new(self, self.source, dir, f)
|
draft = Draft.new(self, self.source, dir, f)
|
||||||
|
|
||||||
self.posts << draft
|
aggregate_post_info(draft)
|
||||||
draft.categories.each { |c| self.categories[c] << draft }
|
|
||||||
draft.tags.each { |c| self.tags[c] << draft }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -403,5 +399,16 @@ module Jekyll
|
||||||
return [] unless File.exists?(base)
|
return [] unless File.exists?(base)
|
||||||
entries = Dir.chdir(base) { filter_entries(Dir['**/*']) }
|
entries = Dir.chdir(base) { filter_entries(Dir['**/*']) }
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue