Skip to content

Instantly share code, notes, and snippets.

@nukos
Last active August 29, 2015 14:13
Show Gist options
  • Save nukos/52fd8e2ee9444bf94e59 to your computer and use it in GitHub Desktop.
Save nukos/52fd8e2ee9444bf94e59 to your computer and use it in GitHub Desktop.
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