From bbcfc701b4f7248e26d420f8abd6292e816bf112 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 26 Oct 2023 18:08:14 -0300 Subject: [PATCH] feat: poder pasar la ruta a Post.build (cherry picked from commit b0c21f989e7b6cf77b41b732e0f08e88d676c4d8) --- app/models/post.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 84f18386..af2b48d4 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -38,19 +38,22 @@ class Post # Genera un Post nuevo # + # @todo Mergear en Post#initialize + # @params :path [String] # @params :site [Site] # @params :locale [String, Symbol] # @params :document [Jekyll::Document] # @params :layout [String,Symbol] # @return [Post] def build(**args) + args[:path] ||= '' 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 + Jekyll::Document.new(args[:path], site: site.jekyll, collection: collection).tap do |doc| + doc.data['date'] ||= Date.today.to_time end end