-
Notifications
You must be signed in to change notification settings - Fork 20
/
_breadcrumbs.html.erb
36 lines (33 loc) · 1.28 KB
/
_breadcrumbs.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<%
breadcrumbs ||= []
collapse_on_mobile ||= false
inverse ||= false
collapse_class = collapse_on_mobile && breadcrumbs.any? { |crumb| crumb[:is_page_parent] } ? "gem-c-breadcrumbs--collapse-on-mobile" : ""
invert_class = inverse ? "gem-c-breadcrumbs--inverse" : ""
breadcrumb_presenter = GovukPublishingComponents::Presenters::Breadcrumbs.new(breadcrumbs, request.path)
%>
<script type="application/ld+json">
<%= raw breadcrumb_presenter.structured_data.to_json %>
</script>
<div class="gem-c-breadcrumbs govuk-breadcrumbs <%= invert_class %>" data-module="track-click">
<ol class="govuk-breadcrumbs__list">
<% breadcrumbs.each_with_index do |crumb, index| %>
<% breadcrumb = GovukPublishingComponents::Presenters::Breadcrumb.new(crumb, index) %>
<li class="govuk-breadcrumbs__list-item" aria-current="<%= breadcrumb.aria_current %>">
<% if breadcrumb.is_link? %>
<%= link_to(
breadcrumb[:title],
breadcrumb.path,
data: breadcrumb.tracking_data(breadcrumbs.length),
class: "govuk-breadcrumbs__link",
aria: {
current: breadcrumb.aria_current,
}
) %>
<% else %>
<%= breadcrumb[:title] %>
<% end %>
</li>
<% end %>
</ol>
</div>