Untitled

mail@pastecode.io avatar
unknown
ruby
11 days ago
1.4 kB
1
Indexable
Never
module MetaTagsHelper
  def yield_head_meta_tag
    current_partner_profile
    tag_value = @page_title || "Facility hire in the UK - #{partner_by_request&.title || 'SchoolHire'}"

    t = meta_tags(:head_title).last
    tag_value = t.tag_value unless t.nil?

    content_tag(:title, tag_value).html_safe
  end

  def yield_meta_tags
    capture do
      if !Rails.env.production? || controller_name == 'opportunities' || @noindex
        concat(tag(:meta, name: :robots, content: :noindex))
      end

      if !Rails.env.production? && @noindex
        concat(tag(:meta, name: 'production-robots', content: :noindex))
      end

      meta_tags.map do |meta_tag|
        concat(tag(:meta, name: meta_tag.tag_attribute_name, content: meta_tag.tag_attribute_content))
      end

      if meta_tags.select { |t| t.tag_attribute_name == 'description' }.count.zero?
        meta_description_content = (@meta_description_content || default_meta_description_content)
        concat(tag(:meta, name: 'description', content: meta_description_content))
      end
    end
  end

  def default_meta_description_content
    facilities = ['sports hall', 'conference room', 'event venue', 'football pitch', 'swimming pool', 'classroom']
    "Hire a #{facilities.join(', ')} or any facility you need near you in just minutes. Real pictures and online booking"
  end
end
Leave a Comment