Skip to content

Commit aed152f

Browse files
CCM-10850: add sidebar section ordering (#115)
* feat(navigation): add sidebar section ordering * Introduced a new YAML file to define the order of sections in the sidebar navigation. * Updated the page layout to utilize the defined section order, ensuring sections not listed appear at the end in alphabetical order. * fix(page layout): remove unnecessary blank lines in page.html
1 parent 7cb78e9 commit aed152f

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Section ordering for sidebar navigation
2+
# Add sections in the order you want them to appear
3+
# Sections not listed here will appear at the end in alphabetical order
4+
5+
sections:
6+
- "By use case"
7+
- "Accessing NHS Notify"
8+
- "Writing a message"
9+
- "Sending a message"

docs/_layouts/page.html

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,36 @@
1616
assign first_level = nav_pages
1717
| where_exp: "item", "item.dir == first_level_dir"
1818
| group_by: "section"
19-
| sort: 'name', 'last'
2019
-%}
20+
21+
{%- assign section_order = site.data.sidebar-section-order.sections -%}
22+
23+
{%- assign ordered_sections = "" | split: "" -%}
24+
{%- for section_name in section_order -%}
25+
{%- for section in first_level -%}
26+
{%- if section.name == section_name -%}
27+
{%- assign ordered_sections = ordered_sections | push: section -%}
28+
{%- break -%}
29+
{%- endif -%}
30+
{%- endfor -%}
31+
{%- endfor -%}
32+
33+
{%- comment -%}
34+
Add any sections not in the manual order list at the end
35+
{%- endcomment -%}
36+
{%- for section in first_level -%}
37+
{%- assign found = false -%}
38+
{%- for ordered_section in ordered_sections -%}
39+
{%- if section.name == ordered_section.name -%}
40+
{%- assign found = true -%}
41+
{%- break -%}
42+
{%- endif -%}
43+
{%- endfor -%}
44+
{%- unless found -%}
45+
{%- assign ordered_sections = ordered_sections | push: section -%}
46+
{%- endunless -%}
47+
{%- endfor -%}
48+
2149
<div class="nhsuk-width-container">
2250
{%- include breadcrumb.html -%}
2351
<main class="nhsuk-main-wrapper--s" id="maincontent" role="main">
@@ -27,7 +55,7 @@
2755
<div class="nhsnotify-pane__side-bar">
2856
<nav class="nhsnotify-side-nav">
2957
<ul class="nhsuk-list nhsnotify-side-nav__list">
30-
{% for section in first_level %}
58+
{% for section in ordered_sections %}
3159
{% if section.name != "" %}
3260
<li class="nhsuk-u-font-weight-bold nhsnotify-side-nav__list-section">{{ section.name }}</li>
3361
{% endif %}

0 commit comments

Comments
 (0)