|
16 | 16 | assign first_level = nav_pages |
17 | 17 | | where_exp: "item", "item.dir == first_level_dir" |
18 | 18 | | group_by: "section" |
19 | | -| sort: 'name', 'last' |
20 | 19 | -%} |
| 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 | + |
21 | 49 | <div class="nhsuk-width-container"> |
22 | 50 | {%- include breadcrumb.html -%} |
23 | 51 | <main class="nhsuk-main-wrapper--s" id="maincontent" role="main"> |
|
27 | 55 | <div class="nhsnotify-pane__side-bar"> |
28 | 56 | <nav class="nhsnotify-side-nav"> |
29 | 57 | <ul class="nhsuk-list nhsnotify-side-nav__list"> |
30 | | - {% for section in first_level %} |
| 58 | + {% for section in ordered_sections %} |
31 | 59 | {% if section.name != "" %} |
32 | 60 | <li class="nhsuk-u-font-weight-bold nhsnotify-side-nav__list-section">{{ section.name }}</li> |
33 | 61 | {% endif %} |
|
0 commit comments