Class: GovukPublishingComponents::Presenters::Breadcrumb

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(crumb, index) ⇒ Breadcrumb

Returns a new instance of Breadcrumb.



31
32
33
34
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 31

def initialize(crumb, index)
  @crumb = crumb
  @index = index + 1
end

Instance Method Details

#is_link?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 44

def is_link?
  crumb[:url].present?
end

#item_list_elementObject



36
37
38
39
40
41
42
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 36

def item_list_element
  {
    "@type" => "ListItem",
    "position" => index,
    "item" => list_item_item,
  }
end

#pathObject



48
49
50
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 48

def path
  crumb[:url]
end

#tracking_data(breadcrumbs_length) ⇒ Object



52
53
54
55
56
57
58
59
60
61
# File 'lib/govuk_publishing_components/presenters/breadcrumbs_helper.rb', line 52

def tracking_data(breadcrumbs_length)
  {
    ga4_link: {
      event_name: "navigation",
      type: "breadcrumb",
      index_link: index.to_s,
      index_total: breadcrumbs_length.to_s,
    },
  }
end