Sha256: 08bbe61469ed621387ee21b50c604f7207f45e288bc3d5f21554d8a348d4e8f3

Contents?: true

Size: 1.1 KB

Versions: 24

Compression:

Stored size: 1.1 KB

Contents

class ApplicationController < ActionController::Base
  # https://www.cookieshq.co.uk/posts/easy-seo-metatags-with-rails-4#a-word-about-turbolinks
  before_action :prepare_meta_tags, if: -> { request.get? }
  def prepare_meta_tags(options={})
    site_name   = DEFAULT_TITLE
    title       = [controller_name, action_name].join(" ")
    description = DEFAULT_DESCRIPTION
    image       = options[:image] || href="/assets/images/logo.png"
    keywords     = DEFAULT_KEYWORDS
    current_url = request.url

    # Let's prepare a nice set of defaults
    defaults = {
      site:        site_name,
      title:       title,
      image:       image,
      description: description,
      keywords:    keywords,
      twitter: {
        site_name: site_name,
        site: site_name,
        card: 'summary',
        description: description,
        image: image
      },
      og: {
        url: current_url,
        site_name: site_name,
        title: title,
        image: image,
        description: description,
        type: 'website'
      }
    }

    options.reverse_merge!(defaults)

    set_meta_tags options
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
jinda-0.3.4 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.3.3 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.3.2 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.3.1 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.3.0 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.9 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.8 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.7 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.6 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.5 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.4 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.3 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.2 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.1 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.2.0 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.1.9 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.1.8 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.1.7 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.1.6.6 lib/generators/jinda/templates/app/controllers/application_controller.rb
jinda-0.1.0 lib/generators/jinda/templates/app/controllers/application_controller.rb