Sha256: 59d2132a7bb22d6c8afa4f188213f6cbb80446e34cfd7d2649da30a2102b112b
Contents?: true
Size: 1.49 KB
Versions: 42
Compression:
Stored size: 1.49 KB
Contents
module GovukPublishingComponents module Presenters class GovernmentServiceSchema attr_reader :page def initialize(page) @page = page end def structured_data # http://schema.org/GovernmentService { "@context" => "http://schema.org", "@type" => "GovernmentService", "name" => page.title, "description" => page.description, "url" => page.canonical_url } .merge(provider) .merge(related_services) end private def related_services related_links = page.content_item.dig('links', 'ordered_related_items') return {} unless related_links.present? { "isRelatedTo" => related_links.each_with_object([]) do |link, items| if link['schema_name'] == 'transaction' items << { "@type" => "GovernmentService", "name" => link['title'], "url" => link['web_url'] } end end } end def provider organisations = page.content_item.dig('links', 'organisations') return {} unless organisations.present? providers = organisations.map do |organisation| { "@type" => "GovernmentOrganization", "name" => organisation['title'], "url" => organisation['web_url'] } end { "provider" => providers } end end end end
Version data entries
42 entries across 42 versions & 1 rubygems