Module: Seorel::Helper

Defined in:
lib/seorel/helper.rb

Instance Method Summary collapse

Instance Method Details

#render_descriptionObject



16
17
18
# File 'lib/seorel/helper.rb', line 16

def render_description
   :meta, nil, name: 'description', content: seorel_params.description
end

#render_meta_tagsObject



8
9
10
# File 'lib/seorel/helper.rb', line 8

def render_meta_tags
  [render_title, render_description, render_open_graph, render_twitter_cards].join("\n").html_safe
end

#render_open_graphObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/seorel/helper.rb', line 20

def render_open_graph
  [
    (:meta, nil, property: 'og:type', content: 'website'),
    (:meta, nil, property: 'og:url', content: request.url),
    (:meta, nil, property: 'og:title', content: seorel_params.title),
    (:meta, nil, property: 'og:description', content: seorel_params.description),
    (:meta, nil, property: 'og:image', content: seorel_params.image),
    (:meta, nil, property: 'og:locale', content: seorel_locale)
  ].join("\n").html_safe
end

#render_titleObject



12
13
14
# File 'lib/seorel/helper.rb', line 12

def render_title
   :title, seorel_params.title
end

#render_twitter_cardsObject



31
32
33
34
35
36
37
38
39
# File 'lib/seorel/helper.rb', line 31

def render_twitter_cards
  [
    (:meta, nil, name: 'twitter:card', content: 'summary_large_image'),
    (:meta, nil, name: 'twitter:url', content: request.url),
    (:meta, nil, name: 'twitter:title', content: seorel_params.title),
    (:meta, nil, name: 'twitter:description', content: seorel_params.description),
    (:meta, nil, name: 'twitter:image', content: seorel_params.image)
  ].join("\n").html_safe
end

#seorel_localeObject



3
4
5
6
# File 'lib/seorel/helper.rb', line 3

def seorel_locale
  locale = (I18n.locale.to_s.size == 2) ? "#{I18n.locale}_#{I18n.locale}" : I18n.locale.to_s
  "#{locale[0..1].downcase}_#{locale[3..4].upcase}"
end