5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 23:36:21 +00:00
panel/app/models/metadata_path.rb

41 lines
711 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.extname.blank? ? '.markdown' : document.extname
end
def lang
post.lang
end
def slug
post.slug.value
end
def date
post.date.value.strftime('%F')
end
end