Remove our categorization hack, and add category view pages instead.
This commit is contained in:
@ -1,9 +0,0 @@
|
||||
# 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
|
30
_plugins/category_page.rb
Normal file
30
_plugins/category_page.rb
Normal file
@ -0,0 +1,30 @@
|
||||
class CategoryPage < Jekyll::Page
|
||||
def initialize(site, base, dir, category)
|
||||
@site = site
|
||||
@base = base
|
||||
@dir = dir
|
||||
@name = 'index.html'
|
||||
|
||||
self.process(@name)
|
||||
self.read_yaml(File.join(base, '_layouts'), 'category_index.html')
|
||||
self.data['category'] = category
|
||||
|
||||
category_title = site.config['category_titles'][category] || category.capitalize
|
||||
self.data['title'] = "#{category_title}"
|
||||
end
|
||||
end
|
||||
|
||||
class CategoryPageGenerator < Jekyll::Generator
|
||||
safe true
|
||||
|
||||
def generate(site)
|
||||
if !site.layouts.key? 'category_index'
|
||||
return
|
||||
end
|
||||
|
||||
site.categories.each_key do |category|
|
||||
site.pages << CategoryPage.new(site, site.source, category, category)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user