mirror of
https://github.com/danbee/danbarber.me
synced 2025-03-04 08:59:10 +00:00
Add categories plugin
This commit is contained in:
parent
046007e519
commit
9d77b9075f
@ -100,4 +100,4 @@ DEPENDENCIES
|
||||
uglifier
|
||||
|
||||
BUNDLED WITH
|
||||
1.11.2
|
||||
1.12.5
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
{% capture category %}{% if post %}{{ post.categories | category_links | size }}{% else %}{{ page.categories | category_links | size }}{% endif %}{% endcapture %}
|
||||
{% capture category %}{% if post %}{{ post.categories | category_list | size }}{% else %}{{ page.categories | category_list | size }}{% endif %}{% endcapture %}
|
||||
{% unless category == '0' %}
|
||||
<span class="categories">
|
||||
{% if post %}
|
||||
{{ post.categories | category_links }}
|
||||
{{ post.categories | category_list }}
|
||||
{% else %}
|
||||
{{ page.categories | category_links }}
|
||||
{{ page.categories | category_list }}
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endunless %}
|
||||
|
||||
15
_plugins/categories.rb
Normal file
15
_plugins/categories.rb
Normal file
@ -0,0 +1,15 @@
|
||||
module Jekyll
|
||||
module Filters
|
||||
|
||||
# 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.
|
||||
#
|
||||
# +categories+ is the list of categories to format.
|
||||
#
|
||||
# Returns string
|
||||
#
|
||||
def category_list(categories)
|
||||
categories.sort.join(', ')
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue
Block a user