From 1c1dd05b36781dbb7bbdae9caa4f67414e809735 Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Fri, 3 Nov 2023 13:58:35 +0100 Subject: [PATCH] Heading level --- app/models/communication/block.rb | 6 ++++++ app/views/admin/communication/blocks/_static.html.erb | 1 + 2 files changed, 7 insertions(+) diff --git a/app/models/communication/block.rb b/app/models/communication/block.rb index 8ed12e14a..6c62ac2d1 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 @@ def full_text 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 77e6feed7..c19209abb 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,