Sha256: 117a3e51a6b21534da4a98578d2396512798a6b39f5c133eca532b688b853b5a

Contents?: true

Size: 712 Bytes

Versions: 5

Compression:

Stored size: 712 Bytes

Contents

require 'plek'

module GovukPublishingComponents
  module Presenters
    class PotentialSearchActionSchema
      attr_reader :facet_params

      BASE_SEARCH_URL = "#{Plek.current.website_root}/search/all?keywords={query}&order=relevance".freeze

      def initialize(facet_params)
        @facet_params = facet_params
      end

      def structured_data
        # http://schema.org/SearchAction - minimal
        {
          "potentialAction" => {
            "@type": "SearchAction",
            "target": search_template,
            "query": "required"
          }
        }
      end

    private

      def search_template
        "#{BASE_SEARCH_URL}&#{facet_params.to_query}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
govuk_publishing_components-16.27.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-16.26.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-16.25.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-16.24.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-16.23.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb