Fix site to categorize and show categories automatically.
This commit is contained in:
parent
0820479a9e
commit
a86f57ec7f
5 changed files with 30 additions and 21 deletions
9
_plugins/auto_categories.rb
Normal file
9
_plugins/auto_categories.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Very simple plugin that adds a subdirectory under _posts as a category
|
||||
|
||||
def get_category_from_subdir(path)
|
||||
path.sub(/^.*_posts\/(.*?)\/.*$/, "\\1")
|
||||
end
|
||||
|
||||
Jekyll::Hooks.register :posts, :pre_render do |post, payload|
|
||||
post.data['categories'] << get_category_from_subdir(post.path)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue