projects
/
web.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
link to talk recording
[web.git]
/
personal
/
_plugins
/
categories.rb
diff --git
a/personal/_plugins/categories.rb
b/personal/_plugins/categories.rb
index 69375dac3b699f1d73bfca2af598b155a33ee6a6..3e0fabec3e192b54829c645455b1f4c806376815 100644
(file)
--- a/
personal/_plugins/categories.rb
+++ b/
personal/_plugins/categories.rb
@@
-9,9
+9,9
@@
module Jekyll
self.process(@name)
self.read_yaml(File.join(base, '_layouts'), layout)
self.process(@name)
self.read_yaml(File.join(base, '_layouts'), layout)
- self.data['category'] = category
+ self.data['category'] = category
# this tells the site template to add a link to the RSS feed
- category_title_prefix = site.config['blog']['
category_title_prefix'] || 'Category: '
+ category_title_prefix = site.config['blog']['
title'] + ": "
self.data['title'] = "#{category_title_prefix}#{category.capitalize}"
end
end
self.data['title'] = "#{category_title_prefix}#{category.capitalize}"
end
end
@@
-20,6
+20,7
@@
module Jekyll
safe true
def generate(site)
safe true
def generate(site)
+ return if site.config['blog'].nil?
dir = site.config['blog']['category_dir'] || 'categories'
if site.layouts.key? 'category_index'
site.categories.each_key do |category|
dir = site.config['blog']['category_dir'] || 'categories'
if site.layouts.key? 'category_index'
site.categories.each_key do |category|
@@
-35,7
+36,7
@@
module Jekyll
end
# Adds some extra filters used during the category creation process.
end
# Adds some extra filters used during the category creation process.
- module
Filters
+ module
CategoryFilter
# Outputs a list of categories as comma-separated <a> links. This is used
# to output the category list for each post on a category page.
# Outputs a list of categories as comma-separated <a> links. This is used
# to output the category list for each post on a category page.
@@
-44,11
+45,9
@@
module Jekyll
#
# Returns string
def category_links(categories)
#
# Returns string
def category_links(categories)
- base_dir = @context.registers[:site].config['blog']['category_dir']
+ cat_base_dir = File.join(@context.registers[:site].config['baseurl'], @context.registers[:site].config['blog']['category_dir'])
categories = categories.sort!.map do |category|
categories = categories.sort!.map do |category|
- category_url = File.join(base_dir, "#{category}.html")
- # Make sure the category directory begins with a slash.
- category_dir = "/#{category_dir}" unless category_dir =~ /^\//
+ category_url = File.join(cat_base_dir, "#{category}.html")
"<a class='category' href='#{category_url}'>#{category.capitalize}</a>"
end
"<a class='category' href='#{category_url}'>#{category.capitalize}</a>"
end
@@
-63,3
+62,5
@@
module Jekyll
end
end
end
end
end
end
+
+Liquid::Template.register_filter(Jekyll::CategoryFilter)