mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 01:56:22 +00:00
41 lines
725 B
Ruby
41 lines
725 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
|
|
|
|
def 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
|
|
|
|
private
|
|
|
|
def ext
|
|
document.data['ext'].blank? ? '.markdown' : document.data['ext']
|
|
end
|
|
|
|
def lang
|
|
post.lang.value
|
|
end
|
|
|
|
def slug
|
|
post.slug.value
|
|
end
|
|
|
|
def date
|
|
post.date.value.strftime('%F')
|
|
end
|
|
end
|