Fix site to categorize and show categories automatically.

This commit is contained in:
Anna Rose Wiggins 2016-04-11 18:01:41 -04:00
parent 0820479a9e
commit a86f57ec7f
5 changed files with 30 additions and 21 deletions

View 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