Sha256: fb493dff8f461e5cc8054af2ab78fd697ea68c5c1f05e90159fbfbe2a42dbc7a

Contents?: true

Size: 816 Bytes

Versions: 17

Compression:

Stored size: 816 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module Rendering
    class LinkToFacet < AbstractStep
      def render
        return next_step(values) unless config.link_to_facet && html?

        next_step(render_link)
      end

      private

      # This allows the link to wrap an itemprop
      def render_link
        values.map { |v| link(link_field, v) }
      end

      def link_field
        return config.key if config.link_to_facet == true

        config.link_to_facet
      end

      def link(field, v)
        context.link_to v, search_path(field, v)
      end

      def search_path(field, v)
        context.search_action_path(facet_params(field, v))
      end

      def facet_params(field, item)
        context.search_state.reset.filter(field).add(item).params
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
blacklight-8.6.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.6.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.5.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.5.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.4.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.3.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.2.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.2.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.2.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.1.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.0.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.0.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.0.0.beta8 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.0.0.beta7 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.0.0.beta6 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-8.0.0.beta5 app/presenters/blacklight/rendering/link_to_facet.rb