Class: Shimmer::Meta

Inherits:
Object
  • Object
show all
Defined in:
lib/shimmer/utils/meta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#canonicalObject

Returns the value of attribute canonical.



6
7
8
# File 'lib/shimmer/utils/meta.rb', line 6

def canonical
  @canonical
end

#descriptionObject

Returns the value of attribute description.



6
7
8
# File 'lib/shimmer/utils/meta.rb', line 6

def description
  @description
end

#imageObject

Returns the value of attribute image.



6
7
8
# File 'lib/shimmer/utils/meta.rb', line 6

def image
  @image
end

#titleObject

Returns the value of attribute title.



6
7
8
# File 'lib/shimmer/utils/meta.rb', line 6

def title
  @title
end

Instance Method Details

#tagsObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shimmer/utils/meta.rb', line 8

def tags
  tags = []
  title = self.title.present? ? "#{self.title} | #{app_name}" : app_name
  tags.push(type: :title, value: title)
  tags.push(property: "og:title", content: title)
  if description.present?
    tags.push(name: :description, content: description)
    tags.push(property: "og:description", content: description)
  end
  if image.present?
    tags.push(property: "og:image", content: image)
  end
  if canonical.present?
    tags.push(type: :link, rel: :canonical, href: canonical)
    tags.push(property: "og:url", content: canonical)
  end
  tags.push(property: "og:type", content: :website)
  tags.push(property: "og:locale", content: I18n.locale)
  tags.push(name: "twitter:card", content: :summary_large_image)
  tags
end