From 7493f15cdc89d462619286314a844e2f8eebc550 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Fri, 24 Jan 2025 22:44:43 +0100 Subject: more minor tweaks --- _plugins/filters.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to '_plugins') 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) -- cgit v1.2.3