Allows category_link to be used as a filter to display a link to
any category.
... | ... |
@@ -141,10 +141,7 @@ module Jekyll |
141 | 141 |
# Returns string |
142 | 142 |
# |
143 | 143 |
def category_links(categories) |
144 |
- dir = @context.registers[:site].config['category_dir'] |
|
145 |
- categories = categories.sort!.map do |item| |
|
146 |
- "<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>" |
|
147 |
- end |
|
144 |
+ categories = categories.sort!.map { |c| category_link c } |
|
148 | 145 |
|
149 | 146 |
case categories.length |
150 | 147 |
when 0 |
... | ... |
@@ -156,6 +153,17 @@ module Jekyll |
156 | 156 |
end |
157 | 157 |
end |
158 | 158 |
|
159 |
+ # Outputs a single category as an <a> link. |
|
160 |
+ # |
|
161 |
+ # +category+ is a category string to format as an <a> link |
|
162 |
+ # |
|
163 |
+ # Returns string |
|
164 |
+ # |
|
165 |
+ def category_link(category) |
|
166 |
+ dir = @context.registers[:site].config['category_dir'] |
|
167 |
+ "<a class='category' href='/#{dir}/#{category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{category}</a>" |
|
168 |
+ end |
|
169 |
+ |
|
159 | 170 |
# Outputs the post.date as formatted html, with hooks for CSS styling. |
160 | 171 |
# |
161 | 172 |
# +date+ is the date object to format as HTML. |