empezar a implementar layouts

This commit is contained in:
f 2019-10-31 17:34:23 -03:00
parent da58998039
commit 8d622d625f
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
3 changed files with 3 additions and 5 deletions

View file

@ -31,8 +31,7 @@ class PostsController < ApplicationController
def new
authorize Post
@site = find_site
# TODO: Implementar layout
@post = @site.posts.build(lang: I18n.locale)
@post = @site.posts.build(lang: I18n.locale, layout: params[:layout])
end
def create

View file

@ -57,7 +57,7 @@ class PostRelation < Array
def build_layout(layout = nil)
return layout if layout.is_a? Layout
site.layouts[layout || :post]
site.layouts[layout.try(:to_sym) || :post]
end
# Devuelve una colección Jekyll que hace pasar el documento

View file

@ -206,8 +206,7 @@ class Site < ApplicationRecord
# @return Array
def everything_of(attr, lang: nil)
posts(lang: lang).map do |p|
# XXX: Tener cuidado con los métodos que no existan
p.send(attr).try :value
p.send(attr).try(:value) if p.attribute? attr
end.flatten.uniq.compact
end