Sha256: f1637780f2dfe376b2e0ec6fdac2b94ff42fdd10c35e92e3721967f795c944ac

Contents?: true

Size: 987 Bytes

Versions: 27

Compression:

Stored size: 987 Bytes

Contents

# frozen_string_literal: true

module Shimmer
  class Meta
    class_attribute :app_name
    attr_accessor :title, :description, :image, :canonical

    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
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
shimmer-0.0.21 lib/shimmer/utils/meta.rb
shimmer-0.0.20 lib/shimmer/utils/meta.rb
shimmer-0.0.19 lib/shimmer/utils/meta.rb
shimmer-0.0.18 lib/shimmer/utils/meta.rb
shimmer-0.0.17 lib/shimmer/utils/meta.rb
shimmer-0.0.16 lib/shimmer/utils/meta.rb
shimmer-0.0.15 lib/shimmer/utils/meta.rb