removed some duplication from category url generation

This commit is contained in:
Brandon Mathis 2012-05-20 16:43:06 -05:00
parent 5e666bfe6b
commit c06ba58466

View File

@ -150,11 +150,9 @@ module Jekyll
def category_links(categories) def category_links(categories)
dir = @context.registers[:site].config['category_dir'] dir = @context.registers[:site].config['category_dir']
categories = categories.sort!.map do |item| categories = categories.sort!.map do |item|
if dir.nil? or dir.empty? url = item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase
"<a class='category' href='/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>" url = "#{dir}/#{url}" unless dir.nil? or dir.empty?
else "<a class='category' href='/#{url}/'>#{item}</a>"
"<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>"
end
end end
case categories.length case categories.length