5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 20:16:23 +00:00

feat: generar un post nuevo

This commit is contained in:
f 2023-10-06 10:13:32 -03:00
parent ea251e5d5b
commit 59828b3f6a
No known key found for this signature in database

View file

@ -31,14 +31,34 @@ class Post
def find_layout(path)
File.foreach(path).lazy.grep(/^layout: /).take(1).first&.split(' ')&.last&.tr('\'', '')&.tr('"', '')&.to_sym
end
# Genera un Post nuevo
#
# @params :site [Site]
# @params :locale [String, Symbol]
# @params :document [Jekyll::Document]
# @params :layout [String,Symbol]
# @return [Post]
def build(**args)
args[:document] ||=
begin
site = args[:site]
collection = site.collections[args[:locale].to_s]
Jekyll::Document.new('', site: site.jekyll, collection: collection).tap do |doc|
doc.data['date'] = Date.today.to_time
end
end
Post.new(**args)
end
end
# Redefinir el inicializador de OpenStruct
#
# @param site: [Site] el sitio en Sutty
# @param document: [Jekyll::Document] el documento leído por Jekyll
# @param layout: [Layout] la plantilla
#
# @param :site [Site] el sitio en Sutty
# @param :document [Jekyll::Document] el documento leído por Jekyll
# @param :layout [Layout] la plantilla
def initialize(**args)
default_attributes_missing(**args)