Class: Agave::Utils::MetaTags::Base
- Inherits:
-
Object
- Object
- Agave::Utils::MetaTags::Base
show all
- Defined in:
- lib/agave/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.
12
13
14
15
|
# File 'lib/agave/utils/meta_tags/base.rb', line 12
def initialize(item, site)
@item = item
@site = site
end
|
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
10
11
12
|
# File 'lib/agave/utils/meta_tags/base.rb', line 10
def item
@item
end
|
#site ⇒ Object
Returns the value of attribute site.
10
11
12
|
# File 'lib/agave/utils/meta_tags/base.rb', line 10
def site
@site
end
|
Instance Method Details
#card_tag(name, content) ⇒ Object
45
46
47
|
# File 'lib/agave/utils/meta_tags/base.rb', line 45
def card_tag(name, content)
meta_tag(name, content)
end
|
#content_tag(tag_name, content) ⇒ Object
49
50
51
|
# File 'lib/agave/utils/meta_tags/base.rb', line 49
def content_tag(tag_name, content)
{ tag_name: tag_name, content: content }
end
|
37
38
39
|
# File 'lib/agave/utils/meta_tags/base.rb', line 37
def meta_tag(name, content)
tag('meta', name: name, content: content)
end
|
#og_tag(property, content) ⇒ Object
41
42
43
|
# File 'lib/agave/utils/meta_tags/base.rb', line 41
def og_tag(property, content)
tag('meta', property: property, content: content)
end
|
#seo_field_with_fallback(attribute, alternative) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/agave/utils/meta_tags/base.rb', line 17
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.send(seo_field.api_key) &&
item.send(seo_field.api_key).send(attribute)
fallback_seo_value = fallback_seo &&
fallback_seo.send(attribute)
item_seo_value || alternative || fallback_seo_value
end
|
#tag(tag_name, attributes) ⇒ Object
33
34
35
|
# File 'lib/agave/utils/meta_tags/base.rb', line 33
def tag(tag_name, attributes)
{ tag_name: tag_name, attributes: attributes }
end
|