Class: Dato::Utils::MetaTags::Base
- Inherits:
-
Object
- Object
- Dato::Utils::MetaTags::Base
show all
- Defined in:
- lib/dato/utils/meta_tags/base.rb
Direct Known Subclasses
ArticleModifiedTime, ArticlePublisher, Description, Image, OgLocale, OgSiteName, OgType, Robots, Title, TwitterCard, TwitterSite
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(item, site) ⇒ Base
Returns a new instance of Base.
13
14
15
16
|
# File 'lib/dato/utils/meta_tags/base.rb', line 13
def initialize(item, site)
@item = item
@site = site
end
|
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
11
12
13
|
# File 'lib/dato/utils/meta_tags/base.rb', line 11
def item
@item
end
|
#site ⇒ Object
Returns the value of attribute site.
11
12
13
|
# File 'lib/dato/utils/meta_tags/base.rb', line 11
def site
@site
end
|
Instance Method Details
#card_tag(name, content) ⇒ Object
46
47
48
|
# 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) ⇒ Object
50
51
52
|
# File 'lib/dato/utils/meta_tags/base.rb', line 50
def content_tag(tag_name, content)
{ tag_name: tag_name, content: content }
end
|
38
39
40
|
# 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) ⇒ Object
42
43
44
|
# 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) ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# 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) ⇒ Object
34
35
36
|
# File 'lib/dato/utils/meta_tags/base.rb', line 34
def tag(tag_name, attributes)
{ tag_name: tag_name, attributes: attributes }
end
|