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.published = self.is_published
|
||||||
|
|
||||||
self.tags = self.data.pluralized_array("tag", "tags")
|
self.setup_categories
|
||||||
|
self.setup_tags
|
||||||
if self.categories.empty?
|
|
||||||
self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.downcase}
|
|
||||||
end
|
|
||||||
|
|
||||||
self.tags.flatten!
|
|
||||||
self.categories.flatten!
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_published
|
def is_published
|
||||||
|
@ -65,6 +59,18 @@ module Jekyll
|
||||||
end
|
end
|
||||||
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
|
# Get the full path to the directory containing the post files
|
||||||
def containing_dir(source, dir)
|
def containing_dir(source, dir)
|
||||||
return File.join(source, dir, '_posts')
|
return File.join(source, dir, '_posts')
|
||||||
|
|
Loading…
Reference in New Issue