Class: PageStructuredData::Page
- Inherits:
-
Object
- Object
- PageStructuredData::Page
- Defined in:
- app/src/page_structured_data/page.rb
Overview
Basic page metadata for any page
Instance Attribute Summary collapse
-
#breadcrumb ⇒ Object
readonly
Returns the value of attribute breadcrumb.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#extra_title ⇒ Object
readonly
Returns the value of attribute extra_title.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#page_type ⇒ Object
readonly
Returns the value of attribute page_type.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(title:, description: nil, image: nil, extra_title: '', breadcrumb: nil, page_type: nil) ⇒ Page
constructor
rubocop:disable Metrics/ParameterLists.
- #json_lds ⇒ Object
- #page_title ⇒ Object
- #title_with_hierarchies ⇒ Object
Constructor Details
#initialize(title:, description: nil, image: nil, extra_title: '', breadcrumb: nil, page_type: nil) ⇒ Page
rubocop:disable Metrics/ParameterLists
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/src/page_structured_data/page.rb', line 8 def initialize(title:, description: nil, image: nil, # rubocop:disable Metrics/ParameterLists extra_title: '', breadcrumb: nil, page_type: nil) @title = title @description = description @image = image @extra_title = extra_title @breadcrumb = @page_type = page_type @breadcrumb = Breadcrumbs.new if .blank? end |
Instance Attribute Details
#breadcrumb ⇒ Object (readonly)
Returns the value of attribute breadcrumb.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def @breadcrumb end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def description @description end |
#extra_title ⇒ Object (readonly)
Returns the value of attribute extra_title.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def extra_title @extra_title end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def image @image end |
#page_type ⇒ Object (readonly)
Returns the value of attribute page_type.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def page_type @page_type end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def title @title end |
Instance Method Details
#json_lds ⇒ Object
34 35 36 37 38 39 |
# File 'app/src/page_structured_data/page.rb', line 34 def json_lds output = [] output << .json_ld(current_page_title: title) if .present? output << page_type.json_ld if page_type.present? output.join end |
#page_title ⇒ Object
26 27 28 29 30 31 32 |
# File 'app/src/page_structured_data/page.rb', line 26 def page_title result = title_with_hierarchies.join(separator) if base_app_name.present? result += separator + base_app_name end result end |
#title_with_hierarchies ⇒ Object
20 21 22 23 24 |
# File 'app/src/page_structured_data/page.rb', line 20 def title_with_hierarchies current_page = extra_title.present? ? [title, extra_title] : [title] current_page += .titles.reverse if .present? current_page end |