Class: GovukPublishingComponents::Presenters::PotentialSearchActionSchema

Inherits:
Object
  • Object
show all
Defined in:
lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb

Constant Summary collapse

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(facet_params, description) ⇒ PotentialSearchActionSchema

Returns a new instance of PotentialSearchActionSchema.



10
11
12
13
# File 'lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb', line 10

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

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb', line 6

def description
  @description
end

#facet_paramsObject (readonly)

Returns the value of attribute facet_params.



6
7
8
# File 'lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb', line 6

def facet_params
  @facet_params
end

Instance Method Details

#structured_dataObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/govuk_publishing_components/presenters/machine_readable/potential_search_action_schema.rb', line 15

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