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
|
|
|
|
# :label en este caso es el idioma/colección
|
|
|
|
def default_value
|
|
|
|
File.join(site.path, "_#{lang}", "#{date}-#{slug}#{ext}")
|
|
|
|
end
|
|
|
|
|
|
|
|
def value
|
|
|
|
default_value
|
|
|
|
end
|
|
|
|
alias absolute value
|
|
|
|
alias to_s value
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def ext
|
2019-08-08 19:26:47 +00:00
|
|
|
document.extname.blank? ? '.markdown' : document.extname
|
2019-08-08 18:28:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def lang
|
|
|
|
post.lang
|
|
|
|
end
|
|
|
|
|
|
|
|
def slug
|
|
|
|
post.slug.value
|
|
|
|
end
|
|
|
|
|
|
|
|
def date
|
|
|
|
post.date.value.strftime('%F')
|
|
|
|
end
|
|
|
|
end
|