-
Notifications
You must be signed in to change notification settings - Fork 31
/
multipage_layout.html.erb
46 lines (43 loc) · 1.3 KB
/
multipage_layout.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
36
37
38
39
40
41
42
43
44
45
46
<% content_for :head do %>
<%= partial 'partials/cookie_wrapper' %>
<% end %>
<% last_updated_banner = capture do %>
<%= partial 'partials/last_updated' %>
<% end %>
<% html = "#{last_updated_banner} #{yield}" %>
<% content_for :page_description, Snippet.generate(html) %>
<%
directory_name = current_page.path.split("/").first
resources = sitemap.resources.select do |r|
r.path.start_with?(directory_name)
end
content_for :sidebar do
%>
<%= multi_page_table_of_contents(resources, current_page, config, html) %>
<% end %>
<% wrap_layout :core do %>
<%= html %>
<script>
/*
Manually trigger the styling of the 'current page' in the sidebar,
as it does not happen automatically because we are still technically
in single page mode.
*/
(function () {
'use strict'
/*
Cannot use `$(document).ready` on next line as jQuery has not loaded
yet. But we can use jQuery in the callback.
*/
window.addEventListener('load', function () {
try {
new GOVUK.Modules.InPageNavigation().start($("html"));
}
catch (error) {
/* Fail without causing other JS in the page to break */
console.log("Error calling GOVUK's InPageNavigation module", error);
}
})
}());
</script>
<% end %>