jekyll(last_modified_at): fallback to mtime on rescue

if fallback doesn't work like for pageless redirections,
use current time as best effort.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-11-11 20:45:40 +01:00
parent fef23f68c2
commit e0d9ce4e9e
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
1 changed files with 7 additions and 1 deletions

View File

@ -46,7 +46,13 @@ module Jekyll
set_mode = "git"
end
rescue => e
# Ignored
begin
page.data['last_modified_at'] = File.mtime(page_relative_path).strftime(DATE_FORMAT)
set_mode = "mtime"
rescue => e
page.data['last_modified_at'] = Time.now.strftime(DATE_FORMAT)
set_mode = "rescue"
end
end
end
puts" #{page.relative_path}#{path_override}\n last_modified_at(#{set_mode}): #{page.data['last_modified_at']}"