mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-14 17:51:41 +00:00
45 lines
855 B
Ruby
45 lines
855 B
Ruby
# frozen_string_literal: true
|
|
|
|
# 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
|
|
|
|
# El valor no vuelve desde el documento
|
|
def value_from_document
|
|
document.path
|
|
end
|
|
|
|
def value
|
|
self[:value] = default_value
|
|
end
|
|
alias absolute value
|
|
alias to_s value
|
|
|
|
def relative
|
|
Pathname.new(value).relative_path_from(Pathname.new(site.path)).to_s
|
|
end
|
|
|
|
def basename
|
|
File.basename(value, ext)
|
|
end
|
|
|
|
# No lo aceptamos en los parámetros
|
|
def to_param; end
|
|
|
|
private
|
|
|
|
def ext
|
|
document.data['ext'].blank? ? '.markdown' : document.data['ext']
|
|
end
|
|
|
|
def slug
|
|
post.slug.value
|
|
end
|
|
|
|
def date
|
|
post.date.value.strftime('%F')
|
|
end
|
|
end
|