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.17.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.16.3 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.16.2 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.16.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.16.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.15.2 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.15.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.15.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.14.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.13.5 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.13.4 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.13.3 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.13.2 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.13.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.13.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.12.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.11.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.10.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.9.0 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb
govuk_publishing_components-21.8.1 lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb