diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 8ed12e14ab5761a1260062436416b2d40c2c381e..6c62ac2d1bc6789104f64a51a0a6d78b4287558b 100644 --- a/app/models/communication/block.rb +++ b/app/models/communication/block.rb @@ -39,6 +39,7 @@ class Communication::Block < ApplicationRecord IMAGE_MAX_SIZE = 5.megabytes FILE_MAX_SIZE = 100.megabytes + DEFAULT_HEADING_LEVEL = 2 # h1 is the page title belongs_to :about, polymorphic: true belongs_to :heading, optional: true @@ -152,6 +153,11 @@ class Communication::Block < ApplicationRecord template.full_text end + def heading_level + heading.present? ? heading.level + 1 + : DEFAULT_HEADING_LEVEL + end + def to_s title.blank? ? "#{Communication::Block.model_name.human} #{position}" : "#{title}" diff --git a/app/views/admin/communication/blocks/_static.html.erb b/app/views/admin/communication/blocks/_static.html.erb index 77e6feed7227b6207491f6c5e6a338b7ce05e974..c19209abba1c87538720f5d735e91bcbf4d7ad7c 100644 --- a/app/views/admin/communication/blocks/_static.html.erb +++ b/app/views/admin/communication/blocks/_static.html.erb @@ -7,6 +7,7 @@ should_render_data = block.data && block.data.present? title: >- <%= prepare_text_for_static block.title %> position: <%= block.position %> + heading_level: <%= block.heading_level %> data: <%= render template_path, block: block,