diff options
author | Brandon Mathis <brandon@imathis.com> | 2012-12-29 00:05:37 -0800 |
---|---|---|
committer | Brandon Mathis <brandon@imathis.com> | 2012-12-29 00:05:37 -0800 |
commit | ce7f6e92a21de9e00545a24be40e84268a7c1843 (patch) | |
tree | 4843be6ebfaa8c62a53cc8a626b02045bf4082d6 /plugins | |
parent | 55fa9b3d8e82e5e2699e4d30a77a71bac26ba443 (diff) | |
parent | 02dac280d0c74a0109e09b613b0a0714caebaf35 (diff) | |
download | my_new_personal_website-ce7f6e92a21de9e00545a24be40e84268a7c1843.tar.xz my_new_personal_website-ce7f6e92a21de9e00545a24be40e84268a7c1843.zip |
Merge pull request #408 from dtchepak/category_link_filter
Extract category_link filter from category_generator.rb plugin
Diffstat (limited to '')
-rw-r--r-- | plugins/category_generator.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/plugins/category_generator.rb b/plugins/category_generator.rb index bb5fd329..77e06afb 100644 --- a/plugins/category_generator.rb +++ b/plugins/category_generator.rb @@ -141,10 +141,7 @@ module Jekyll # Returns string # def category_links(categories) - dir = @context.registers[:site].config['category_dir'] - categories = categories.sort!.map do |item| - "<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>" - end + categories = categories.sort!.map { |c| category_link c } case categories.length when 0 @@ -156,6 +153,17 @@ module Jekyll end end + # Outputs a single category as an <a> link. + # + # +category+ is a category string to format as an <a> link + # + # Returns string + # + def category_link(category) + dir = @context.registers[:site].config['category_dir'] + "<a class='category' href='/#{dir}/#{category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{category}</a>" + end + # Outputs the post.date as formatted html, with hooks for CSS styling. # # +date+ is the date object to format as HTML. |