Skip to content

Instantly share code, notes, and snippets.

@nukos

nukos/tag_order.rb

Last active Aug 29, 2015
Embed
What would you like to do?
Sort the tag of jekyll in Posts.
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