Refactor Post category instantiation
This commit is contained in:
parent
482986e346
commit
6d9845a58b
|
@ -47,14 +47,8 @@ module Jekyll
|
|||
|
||||
self.published = self.is_published
|
||||
|
||||
self.tags = self.data.pluralized_array("tag", "tags")
|
||||
|
||||
if self.categories.empty?
|
||||
self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.downcase}
|
||||
end
|
||||
|
||||
self.tags.flatten!
|
||||
self.categories.flatten!
|
||||
self.setup_categories
|
||||
self.setup_tags
|
||||
end
|
||||
|
||||
def is_published
|
||||
|
@ -65,6 +59,18 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
def setup_categories
|
||||
if self.categories.empty?
|
||||
self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.downcase}
|
||||
end
|
||||
self.categories.flatten!
|
||||
end
|
||||
|
||||
def setup_tags
|
||||
self.tags = self.data.pluralized_array("tag", "tags")
|
||||
self.tags.flatten!
|
||||
end
|
||||
|
||||
# Get the full path to the directory containing the post files
|
||||
def containing_dir(source, dir)
|
||||
return File.join(source, dir, '_posts')
|
||||
|
|
Loading…
Reference in New Issue