mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-24 12:56:21 +00:00
59 lines
1.1 KiB
Ruby
59 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# Este campo representa el archivo donde se almacenan los datos
|
|
class MetadataPath < MetadataTemplate
|
|
include Metadata::NonIndexableConcern
|
|
include Metadata::AlwaysPublicConcern
|
|
|
|
# :label en este caso es el idioma/colección
|
|
#
|
|
# @return [String]
|
|
def default_value
|
|
File.join(site.path, "_#{lang}", "#{date}-#{slug}#{ext}")
|
|
end
|
|
|
|
# La ruta del archivo según Jekyll
|
|
#
|
|
# @return [String]
|
|
def document_value
|
|
document.path
|
|
end
|
|
|
|
def value
|
|
self[:value] = default_value
|
|
end
|
|
alias absolute value
|
|
alias to_s value
|
|
|
|
# @return [String]
|
|
def relative
|
|
Pathname.new(value).relative_path_from(Pathname.new(site.path)).to_s
|
|
end
|
|
|
|
# @return [String]
|
|
def basename
|
|
File.basename(value, ext)
|
|
end
|
|
|
|
# No lo aceptamos en los parámetros
|
|
def to_param; end
|
|
|
|
private
|
|
|
|
# Obtiene la extensión
|
|
#
|
|
# @return [String]
|
|
def ext
|
|
document.data['ext'].blank? ? '.markdown' : document.data['ext']
|
|
end
|
|
|
|
# @return [String]
|
|
def slug
|
|
post.slug.value
|
|
end
|
|
|
|
# @return [String]
|
|
def date
|
|
post.date.value.strftime('%F')
|
|
end
|
|
end
|