Class: GovukTechDocs::MetaTags
- Inherits:
-
Object
- Object
- GovukTechDocs::MetaTags
- Defined in:
- lib/govuk_tech_docs/meta_tags.rb
Instance Method Summary collapse
- #browser_title ⇒ Object
- #canonical_url ⇒ Object
-
#initialize(config, current_page) ⇒ MetaTags
constructor
A new instance of MetaTags.
- #tags ⇒ Object
Constructor Details
#initialize(config, current_page) ⇒ MetaTags
Returns a new instance of MetaTags.
3 4 5 6 |
# File 'lib/govuk_tech_docs/meta_tags.rb', line 3 def initialize(config, current_page) @config = config @current_page = current_page end |
Instance Method Details
#browser_title ⇒ Object
27 28 29 |
# File 'lib/govuk_tech_docs/meta_tags.rb', line 27 def browser_title [page_title, site_name].select(&:present?).uniq.join(' | ') end |
#canonical_url ⇒ Object
31 32 33 |
# File 'lib/govuk_tech_docs/meta_tags.rb', line 31 def canonical_url "#{host}#{current_page.url}" end |
#tags ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/govuk_tech_docs/meta_tags.rb', line 8 def = { 'description' => page_description, 'og:description' => page_description, 'og:image' => page_image, 'og:site_name' => site_name, 'og:title' => page_title, 'og:type' => 'object', 'og:url' => canonical_url, 'twitter:card' => 'summary', 'twitter:domain' => URI.parse(host).host, 'twitter:image' => page_image, 'twitter:title' => browser_title, 'twitter:url' => canonical_url, } Hash[.select { |_k, v| v }] end |