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
-
#base_app_name ⇒ Object
readonly
Returns the value of attribute base_app_name.
-
#breadcrumb ⇒ Object
readonly
Returns the value of attribute breadcrumb.
-
#canonical_url ⇒ Object
readonly
Returns the value of attribute canonical_url.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#extra_title ⇒ Object
readonly
Returns the value of attribute extra_title.
-
#fallback_image ⇒ Object
readonly
Returns the value of attribute fallback_image.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
-
#page_type ⇒ Object
readonly
Returns the value of attribute page_type.
-
#page_types ⇒ Object
readonly
Returns the value of attribute page_types.
-
#render_breadcrumb_json_ld ⇒ Object
readonly
Returns the value of attribute render_breadcrumb_json_ld.
-
#robots ⇒ Object
readonly
Returns the value of attribute robots.
-
#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_types: nil, canonical_url: nil, fallback_image: nil, base_app_name: nil, render_breadcrumb_json_ld: nil, robots: nil) ⇒ Page
constructor
rubocop:disable Metrics/ParameterLists.
- #json_lds ⇒ Object
- #page_title ⇒ Object
- #resolved_image ⇒ Object
- #robots_content ⇒ Object
- #title_with_hierarchies ⇒ Object
- #valid? ⇒ Boolean
- #warnings ⇒ Object
Constructor Details
#initialize(title:, description: nil, image: nil, extra_title: '', breadcrumb: nil, page_type: nil, page_types: nil, canonical_url: nil, fallback_image: nil, base_app_name: nil, render_breadcrumb_json_ld: nil, robots: nil) ⇒ Page
rubocop:disable Metrics/ParameterLists
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/src/page_structured_data/page.rb', line 9 def initialize(title:, description: nil, image: nil, # rubocop:disable Metrics/ParameterLists extra_title: '', breadcrumb: nil, page_type: nil, page_types: nil, canonical_url: nil, fallback_image: nil, base_app_name: nil, render_breadcrumb_json_ld: nil, robots: nil) @title = title @description = description @image = image @extra_title = extra_title @breadcrumb = @page_type = page_type @page_types = page_types @canonical_url = canonical_url @fallback_image = fallback_image @base_app_name = base_app_name @render_breadcrumb_json_ld = @robots = robots end |
Instance Attribute Details
#base_app_name ⇒ Object (readonly)
Returns the value of attribute base_app_name.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def base_app_name @base_app_name end |
#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 |
#canonical_url ⇒ Object (readonly)
Returns the value of attribute canonical_url.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def canonical_url @canonical_url 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 |
#fallback_image ⇒ Object (readonly)
Returns the value of attribute fallback_image.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def fallback_image @fallback_image 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 |
#page_types ⇒ Object (readonly)
Returns the value of attribute page_types.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def page_types @page_types end |
#render_breadcrumb_json_ld ⇒ Object (readonly)
Returns the value of attribute render_breadcrumb_json_ld.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def @render_breadcrumb_json_ld end |
#robots ⇒ Object (readonly)
Returns the value of attribute robots.
6 7 8 |
# File 'app/src/page_structured_data/page.rb', line 6 def robots @robots 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
40 41 42 43 44 45 |
# File 'app/src/page_structured_data/page.rb', line 40 def json_lds output = [] output << if ( = self.).present? resolved_page_types.each { |resolved_page_type| output << resolved_page_type.json_ld } output.join end |
#page_title ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/src/page_structured_data/page.rb', line 32 def page_title result = title_with_hierarchies.join(separator) if resolved_base_app_name.present? result += separator + resolved_base_app_name end result end |
#resolved_image ⇒ Object
47 48 49 |
# File 'app/src/page_structured_data/page.rb', line 47 def resolved_image image || fallback_image end |
#robots_content ⇒ Object
51 52 53 |
# File 'app/src/page_structured_data/page.rb', line 51 def robots_content Array(robots).compact.join(',') end |
#title_with_hierarchies ⇒ Object
26 27 28 29 30 |
# File 'app/src/page_structured_data/page.rb', line 26 def title_with_hierarchies current_page = extra_title.present? ? [title, extra_title] : [title] current_page += .titles.reverse if .present? current_page end |
#valid? ⇒ Boolean
59 60 61 |
# File 'app/src/page_structured_data/page.rb', line 59 def valid? warnings.empty? end |
#warnings ⇒ Object
55 56 57 |
# File 'app/src/page_structured_data/page.rb', line 55 def warnings page_warnings + page_type_warnings end |