Class: Blacklight::OpenGraphMetadataComponent
- Inherits:
-
Component
- Object
- Component
- Blacklight::OpenGraphMetadataComponent
- Defined in:
- app/components/blacklight/open_graph_metadata_component.rb
Overview
Renders tags in the
with Open Graph metadataInstance Attribute Summary collapse
-
#presenter ⇒ Object
readonly
Returns the value of attribute presenter.
Instance Method Summary collapse
-
#call ⇒ Object
Render all entries in properties as tags.
-
#default_properties ⇒ Object
Base set of properties that will be rendered on every page.
-
#initialize(presenter: nil) ⇒ OpenGraphMetadataComponent
constructor
A new instance of OpenGraphMetadataComponent.
-
#properties ⇒ Object
Hash of property:content pairs that will become tags.
Constructor Details
#initialize(presenter: nil) ⇒ OpenGraphMetadataComponent
Returns a new instance of OpenGraphMetadataComponent.
9 10 11 |
# File 'app/components/blacklight/open_graph_metadata_component.rb', line 9 def initialize(presenter: nil) @presenter = presenter end |
Instance Attribute Details
#presenter ⇒ Object (readonly)
Returns the value of attribute presenter.
6 7 8 |
# File 'app/components/blacklight/open_graph_metadata_component.rb', line 6 def presenter @presenter end |
Instance Method Details
#call ⇒ Object
Render all entries in properties as tags
29 30 31 |
# File 'app/components/blacklight/open_graph_metadata_component.rb', line 29 def call safe_join(properties.map { |property, content| tag.(property:, content: helpers.(content)) }, "\n") end |
#default_properties ⇒ Object
Base set of properties that will be rendered on every page
19 20 21 22 23 24 25 26 |
# File 'app/components/blacklight/open_graph_metadata_component.rb', line 19 def default_properties { 'og:type' => 'website', 'og:site_name' => helpers.application_name, 'og:title' => helpers.render_page_title, 'og:url' => request.original_url } end |
#properties ⇒ Object
Hash of property:content pairs that will become tags
14 15 16 |
# File 'app/components/blacklight/open_graph_metadata_component.rb', line 14 def properties default_properties.merge((presenter&.properties || {}).transform_keys(&:to_s)).compact_blank end |