diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2023-01-02 15:56:01 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2023-01-02 15:56:01 +0100 |
| commit | b4fe8dd78272c8ef7efa82a9602458576d27edf9 (patch) | |
| tree | da098f41fb42a012c252e596836ca18ca9d112f0 /_plugins/log.rb | |
| parent | 0fcf45a6393175f2116478c0e4de63e5393130d5 (diff) | |
| download | jo.mssola.com-b4fe8dd78272c8ef7efa82a9602458576d27edf9.tar.gz jo.mssola.com-b4fe8dd78272c8ef7efa82a9602458576d27edf9.zip | |
Added misc section
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to '_plugins/log.rb')
| -rw-r--r-- | _plugins/log.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/_plugins/log.rb b/_plugins/log.rb index d524e68..99473c5 100644 --- a/_plugins/log.rb +++ b/_plugins/log.rb @@ -19,13 +19,17 @@ require 'date' require_relative 'modified_time_helper' module Jekyll - # Render the last modification time of the given page. + # Render the last modification time of the given page. This plugin requires + # the use of the Jekyll multiple-language plugin, and a value for the + # 'log.unknown' key. class RenderModifiedAt < Liquid::Tag include ::Jekyll::ModifiedTimeHelper def render(context) - time = Time.iso8601(modified_time(context['page'])) + mt = modified_time(context['page']) + return unknown(context) if mt.nil? + time = Time.iso8601(mt) if context['page']['lang'] == 'en' time.strftime('%B %-d, %Y, at %H:%m') else @@ -35,6 +39,14 @@ module Jekyll protected + # Returns the 'log.unknown' string. + def unknown(context) + lang = context['site']['lang'] + ts = context['site']['translations'][lang] + + ts['log']['unknown'] + end + # Given a month number, return its catalan translation. # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity def catalan_month(month) |
