Sha256: 8190ee009da6111a8979c8d16ff3e2ad19c302666ee889a4a57a9d4f16d3e8e6

Contents?: true

Size: 970 Bytes

Versions: 6

Compression:

Stored size: 970 Bytes

Contents

# frozen_string_literal: true

module Archangel
  ##
  # Controller SEO concern
  #
  module SeoableConcern
    extend ActiveSupport::Concern

    included do
      before_action :apply_default_meta_tags, if: -> { request.get? },
                                              unless: -> { request.xhr? }
    end

    # Set meta tags
    #
    # @param meta_tags [Hash] list of meta tags
    def apply_meta_tags(meta_tags = {})
      set_meta_tags(meta_tags.reject { |_name, value| value.blank? })
    end

    protected

    def apply_default_meta_tags
      apply_meta_tags default_meta_tags
    end

    def default_meta_tags
      {
        reverse:     true,
        site:        current_site.name,
        canonical:   request.url,
        image_src:   current_site.logo.url,
        description: current_site.meta_description,
        keywords:    current_site.meta_keywords.to_s.split(","),
        icon:        current_site.favicon.url
      }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
archangel-0.0.7 app/controllers/concerns/archangel/seoable_concern.rb
archangel-0.0.6 app/controllers/concerns/archangel/seoable_concern.rb
archangel-0.0.5 app/controllers/concerns/archangel/seoable_concern.rb
archangel-0.0.4 app/controllers/concerns/archangel/seoable_concern.rb
archangel-0.0.3 app/controllers/concerns/archangel/seoable_concern.rb
archangel-0.0.2 app/controllers/concerns/archangel/seoable_concern.rb