class Dato::Utils::MetaTags::Base
Attributes
item[R]
site[R]
Public Class Methods
new(item, site)
click to toggle source
# File lib/dato/utils/meta_tags/base.rb, line 13 def initialize(item, site) @item = item @site = site end
Public Instance Methods
card_tag(name, content)
click to toggle source
# File lib/dato/utils/meta_tags/base.rb, line 46 def card_tag(name, content) meta_tag(name, content) end
content_tag(tag_name, content)
click to toggle source
# File lib/dato/utils/meta_tags/base.rb, line 50 def content_tag(tag_name, content) { tag_name: tag_name, content: content } end
meta_tag(name, content)
click to toggle source
# File lib/dato/utils/meta_tags/base.rb, line 38 def meta_tag(name, content) tag("meta", name: name, content: content) end
og_tag(property, content)
click to toggle source
# File lib/dato/utils/meta_tags/base.rb, line 42 def og_tag(property, content) tag("meta", property: property, content: content) end
seo_field_with_fallback(attribute, alternative)
click to toggle source
# File lib/dato/utils/meta_tags/base.rb, line 18 def seo_field_with_fallback(attribute, alternative) fallback_seo = site.global_seo && site.global_seo.fallback_seo seo_field = item && item.fields.detect { |f| f.field_type == "seo" } item_seo_value = seo_field && item[seo_field.api_key] && item[seo_field.api_key].send(attribute) fallback_seo_value = fallback_seo && fallback_seo.send(attribute) item_seo_value.presence || alternative.presence || fallback_seo_value end
tag(tag_name, attributes)
click to toggle source
# File lib/dato/utils/meta_tags/base.rb, line 34 def tag(tag_name, attributes) { tag_name: tag_name, attributes: attributes } end