Sha256: ab28f145b7a121bd440ad25e99713c2aa88696295758b854ae6e3e8dac4de55c

Contents?: true

Size: 814 Bytes

Versions: 101

Compression:

Stored size: 814 Bytes

Contents

require 'plek'

module GovukPublishingComponents
  module Presenters
    class PotentialSearchActionSchema
      attr_reader :facet_params, :description

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

      def initialize(facet_params, description)
        @facet_params = facet_params
        @description = description
      end

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

    private

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

Version data entries

101 entries across 101 versions & 1 rubygems

Version Path
govuk_publishing_components-21.27.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.27.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.26.2 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.26.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.26.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.25.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.24.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.23.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.23.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.22.2 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.22.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.22.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.21.3 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.21.2 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.21.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.21.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.20.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.19.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.19.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.18.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb