-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpage.html
More file actions
133 lines (121 loc) · 4.54 KB
/
page.html
File metadata and controls
133 lines (121 loc) · 4.54 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
layout: default
---
{% assign current_dir = page.dir %}
{% assign paths = page.dir | split: "/" %}
{% assign parent_dir = paths[1] %}
{%-
assign nav_pages = site.pages
| where_exp: "item", "item.dir contains parent_dir"
-%}
{% assign first_level_dir = parent_dir | prepend: '/' | append: '/' %}
{%-
assign first_level = nav_pages
| where_exp: "item", "item.dir == first_level_dir"
| group_by: "section"
-%}
{%- comment -%}
Separate pages with sections from pages without sections
{%- endcomment -%}
{%- assign pages_without_sections = "" | split: "" -%}
{%- assign pages_with_sections = "" | split: "" -%}
{%- for section in first_level -%}
{%- if section.name == "" or section.name == nil -%}
{%- assign pages_without_sections = pages_without_sections | concat: section.items -%}
{%- else -%}
{%- assign pages_with_sections = pages_with_sections | push: section -%}
{%- endif -%}
{%- endfor -%}
{%- comment -%}
Sort pages without sections by nav_order
{%- endcomment -%}
{%- assign sorted_pages_without_sections = pages_without_sections | sort: 'nav_order' -%}
{%- assign section_order = site.data.sidebar-section-order.sections -%}
{%- assign ordered_sections = "" | split: "" -%}
{%- for section_name in section_order -%}
{%- for section in pages_with_sections -%}
{%- if section.name == section_name -%}
{%- assign ordered_sections = ordered_sections | push: section -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- endfor -%}
{%- comment -%}
Add any sections not in the manual order list at the end
{%- endcomment -%}
{%- for section in pages_with_sections -%}
{%- assign found = false -%}
{%- for ordered_section in ordered_sections -%}
{%- if section.name == ordered_section.name -%}
{%- assign found = true -%}
{%- break -%}
{%- endif -%}
{%- endfor -%}
{%- unless found -%}
{%- assign ordered_sections = ordered_sections | push: section -%}
{%- endunless -%}
{%- endfor -%}
<div class="nhsuk-width-container">
{%- include breadcrumb.html -%}
<main class="nhsuk-main-wrapper--s" id="maincontent" role="main">
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-full">
<div class="nhsnotify-pane">
<div class="nhsnotify-pane__side-bar">
<nav class="nhsnotify-side-nav">
<ul class="nhsuk-list nhsnotify-side-nav__list">
{%- comment -%}
First render pages without sections (sorted by nav_order)
{%- endcomment -%}
{% for post in sorted_pages_without_sections %}
{% unless post.has_children %}
{% if post.published != false and post.title != "" and post.title != nil %}
<li class="
nhsnotify-side-nav__item
{% if post.url == page.url %}
nhsnotify-side-nav__item--current
{% endif %}
">
<a class="nhsnotify-side-nav__link" href="{{ site.baseurl | append: post.url }}">{{ post.title }}</a>
</li>
{% endif %}
{% endunless %}
{% endfor %}
{%- comment -%}
Then render sections with their pages
{%- endcomment -%}
{% for section in ordered_sections %}
{% if section.name != "" %}
<li class="nhsuk-u-font-weight-bold nhsnotify-side-nav__list-section">{{ section.name }}</li>
{% endif %}
{% assign sorted = section.items | sort: 'nav_order' %}
{% for post in sorted %}
{% unless post.has_children %}
{% if post.published != false and post.title != "" and post.title != nil %}
<li class="
nhsnotify-side-nav__item
{% if post.url == page.url %}
nhsnotify-side-nav__item--current
{% endif %}
">
<a class="nhsnotify-side-nav__link" href="{{ site.baseurl | append: post.url }}">{{ post.title }}</a>
</li>
{% endif %}
{% endunless %}
{% endfor %}
{% endfor %}
</ul>
</nav>
</div>
<div class="nhsnotify-pane__main-content">
{% if page.section != undefined %}
<span class="nhsuk-caption-xl">{{ page.section }}</span>
{% endif %}
<h1 class="nhsuk-heading-xl">{{ page.title }}</h1>
{{ content }}
</div>
</div>
</div>
</div>
</main>
</div>