Last active
August 29, 2015 14:13
-
-
Save nukos/52fd8e2ee9444bf94e59 to your computer and use it in GitHub Desktop.
Sort the tag of jekyll in Posts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
module Filters | |
def tag_order(tags, order, orderby='ASC') | |
# order | |
case order | |
when 'count' then | |
order_tags = tags.sort_by { | t, posts | posts.count } | |
end | |
# orderby | |
case orderby | |
when 'ASC' then | |
orderby_tags = order_tags | |
when 'DESC' then | |
orderby_tags = order_tags.reverse | |
end | |
return orderby_tags | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment