diff options
Diffstat (limited to '_plugins')
-rw-r--r-- | _plugins/filters.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/_plugins/filters.rb b/_plugins/filters.rb index 2526573..9e9b026 100644 --- a/_plugins/filters.rb +++ b/_plugins/filters.rb @@ -8,6 +8,17 @@ module Filters return "#{items[0]}" if items.length == 1 return "#{items[0..-2].join(", ")} and #{items[-1]}" end + + def plural(num, counter) + return "#{num} #{counter}#{counter == 1 ? '' : 's'}" + end + + def post_sort(posts, sort_by) + # date (reverse chronological) + return posts.sort_by{ |post| -post.date.to_i } if sort_by == "date" + # title (case insensitive) + return posts.sort_by{ |post| post.title.downcase } if sort_by == "title" + end end Liquid::Template.register_filter(Filters) |