2019-08-08 19:26:47 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-08 18:28:23 +00:00
|
|
|
# Este campo representa el archivo donde se almacenan los datos
|
|
|
|
class MetadataPath < MetadataTemplate
|
2023-10-06 13:53:19 +00:00
|
|
|
include Metadata::NonIndexableConcern
|
|
|
|
include Metadata::AlwaysPublicConcern
|
|
|
|
|
2019-08-08 18:28:23 +00:00
|
|
|
# :label en este caso es el idioma/colección
|
2021-06-16 14:35:37 +00:00
|
|
|
#
|
|
|
|
# @return [String]
|
2019-08-08 18:28:23 +00:00
|
|
|
def default_value
|
|
|
|
File.join(site.path, "_#{lang}", "#{date}-#{slug}#{ext}")
|
|
|
|
end
|
|
|
|
|
2021-06-16 14:35:37 +00:00
|
|
|
# La ruta del archivo según Jekyll
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
def document_value
|
2021-02-17 21:40:07 +00:00
|
|
|
document.path
|
|
|
|
end
|
|
|
|
|
2019-08-08 18:28:23 +00:00
|
|
|
def value
|
2020-10-04 01:32:52 +00:00
|
|
|
self[:value] = default_value
|
2019-08-08 18:28:23 +00:00
|
|
|
end
|
|
|
|
alias absolute value
|
|
|
|
alias to_s value
|
|
|
|
|
2023-10-06 13:53:19 +00:00
|
|
|
# @return [String]
|
2019-08-08 18:28:23 +00:00
|
|
|
def relative
|
2019-08-09 18:45:08 +00:00
|
|
|
Pathname.new(value).relative_path_from(Pathname.new(site.path)).to_s
|
2019-08-08 18:28:23 +00:00
|
|
|
end
|
|
|
|
|
2023-10-06 13:53:19 +00:00
|
|
|
# @return [String]
|
2019-08-13 19:09:23 +00:00
|
|
|
def basename
|
|
|
|
File.basename(value, ext)
|
|
|
|
end
|
|
|
|
|
2020-03-23 20:50:15 +00:00
|
|
|
# No lo aceptamos en los parámetros
|
|
|
|
def to_param; end
|
|
|
|
|
2019-08-08 18:28:23 +00:00
|
|
|
private
|
|
|
|
|
2023-10-06 13:53:19 +00:00
|
|
|
# Obtiene la extensión
|
|
|
|
#
|
|
|
|
# @return [String]
|
2019-08-08 18:28:23 +00:00
|
|
|
def ext
|
2019-10-18 21:08:43 +00:00
|
|
|
document.data['ext'].blank? ? '.markdown' : document.data['ext']
|
2019-08-08 18:28:23 +00:00
|
|
|
end
|
|
|
|
|
2023-10-06 13:53:19 +00:00
|
|
|
# @return [String]
|
2019-08-08 18:28:23 +00:00
|
|
|
def slug
|
|
|
|
post.slug.value
|
|
|
|
end
|
|
|
|
|
2023-10-06 13:53:19 +00:00
|
|
|
# @return [String]
|
2019-08-08 18:28:23 +00:00
|
|
|
def date
|
|
|
|
post.date.value.strftime('%F')
|
|
|
|
end
|
|
|
|
end
|