1
0
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:
Daniel Barber 2016-07-29 15:41:25 -05:00
parent 046007e519
commit 9d77b9075f
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
3 changed files with 19 additions and 4 deletions

View File

@ -100,4 +100,4 @@ DEPENDENCIES
uglifier
BUNDLED WITH
1.11.2
1.12.5

View File

@ -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
View 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