Sha256: de405dddc13b8ea82dda4f6d93691eda543909f29964144b9ef700e9663a326b
Contents?: true
Size: 949 Bytes
Versions: 66
Compression:
Stored size: 949 Bytes
Contents
module GovukPublishingComponents module Presenters class Breadcrumbs def initialize(breadcrumbs, request_path) @breadcrumbs = breadcrumbs @request_path = request_path end def structured_data { "@context" => "http://schema.org", "@type" => "BreadcrumbList", "itemListElement" => item_list_element, } end private attr_reader :breadcrumbs, :request_path def item_list_element breadcrumbs.each_with_index.map do |crumb, index| { "@type" => "ListItem", "position" => index + 1, "item" => list_item_item(crumb) } end end def list_item_item(crumb) path = crumb[:is_current_page] ? request_path : crumb[:url] item = { "name" => crumb[:title] } item["@id"] = Plek.new.website_root + path if path item end end end end
Version data entries
66 entries across 66 versions & 1 rubygems