From ee881e22aba10204d953b21958a1f9afacfb0f41 Mon Sep 17 00:00:00 2001 From: f Date: Wed, 7 Apr 2021 17:46:37 -0300 Subject: [PATCH] =?UTF-8?q?no=20ofrecer=20la=20renderizaci=C3=B3n=20de=20l?= =?UTF-8?q?ayouts=20ignorados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/layout.rb | 5 +++++ app/views/posts/show.haml | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/models/layout.rb b/app/models/layout.rb index 2d68273..c70829f 100644 --- a/app/models/layout.rb +++ b/app/models/layout.rb @@ -28,6 +28,11 @@ Layout = Struct.new(:site, :name, :meta, :metadata, keyword_init: true) do meta[:hidden].present? end + # Detecta si el layout no es renderizable + def ignored? + @ignored ||= site.config['ignored_layouts']&.include? name.to_s + end + # Los metadatos del Layout. # # TODO: Inicializar con valores por defecto o usar Hash#default_proc diff --git a/app/views/posts/show.haml b/app/views/posts/show.haml index c6bd1d8..9dd4faa 100644 --- a/app/views/posts/show.haml +++ b/app/views/posts/show.haml @@ -12,12 +12,12 @@ edit_site_post_path(@site, @post.id), class: 'btn btn-block' - = link_to t('posts.preview.btn'), - site_post_preview_path(@site, @post.id), - class: 'btn btn-block', - target: '_blank', - rel: 'noopener' - .alert.alert-info= t('posts.preview.alert') + - unless @post.layout.ignored? + = link_to t('posts.preview.btn'), + site_post_preview_path(@site, @post.id), + class: 'btn btn-block', + target: '_blank', + rel: 'noopener' %table.table.table-condensed %thead