From b4fe8dd78272c8ef7efa82a9602458576d27edf9 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Mon, 2 Jan 2023 15:56:01 +0100 Subject: Added misc section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- _plugins/log.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to '_plugins/log.rb') 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) -- cgit v1.2.3