diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-24 22:44:43 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-24 22:44:43 +0100 |
commit | 7493f15cdc89d462619286314a844e2f8eebc550 (patch) | |
tree | eb1bb6767f0f6b4e6813207e9ba2d4a31b73669d /_plugins | |
parent | 639fece16245dac8c24277cc1ce2f1321f683920 (diff) |
more minor tweaks
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) |