5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-06-02 05:24:17 +00:00

guardar la fecha de modificación en el archivo

last_modified_at es utilizada por jekyll-feed y otros plugins, aunque
nos hubiera gustado updated_at
This commit is contained in:
f 2021-01-25 15:29:14 -03:00
parent c5faba9a6b
commit 996c70f298

View file

@ -141,10 +141,17 @@ class Post < OpenStruct
end
alias to_param id
# Fecha de última modificación del archivo
def updated_at
File.mtime(path.absolute)
end
# Obtiene la fecha actual de modificación y la guarda hasta la próxima
# vez.
def modified_at
@modified_at ||= Time.now
end
# Solo ejecuta la magia de OpenStruct si el campo existe en la
# plantilla
#
@ -215,6 +222,7 @@ class Post < OpenStruct
# Y que no se procese liquid
yaml['liquid'] = false
yaml['usuaries'] = usuaries.map(&:id).uniq
yaml['last_modified_at'] = modified_at
"#{yaml.to_yaml}---\n\n#{body}"
end