diff --git a/docs/_data/sidebar-section-order.yml b/docs/_data/sidebar-section-order.yml new file mode 100644 index 0000000..40a10dc --- /dev/null +++ b/docs/_data/sidebar-section-order.yml @@ -0,0 +1,9 @@ +# Section ordering for sidebar navigation +# Add sections in the order you want them to appear +# Sections not listed here will appear at the end in alphabetical order + +sections: + - "By use case" + - "Accessing NHS Notify" + - "Writing a message" + - "Sending a message" diff --git a/docs/_layouts/page.html b/docs/_layouts/page.html index 28db944..9ee6b05 100644 --- a/docs/_layouts/page.html +++ b/docs/_layouts/page.html @@ -16,8 +16,36 @@ assign first_level = nav_pages | where_exp: "item", "item.dir == first_level_dir" | group_by: "section" -| sort: 'name', 'last' -%} + +{%- assign section_order = site.data.sidebar-section-order.sections -%} + +{%- assign ordered_sections = "" | split: "" -%} +{%- for section_name in section_order -%} + {%- for section in first_level -%} + {%- 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 first_level -%} + {%- 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 -%} +