From 30471a97a2b2d2815165613c4d05faf6fd309d0e Mon Sep 17 00:00:00 2001 From: Colin Burn-Murdoch Date: Wed, 23 Jun 2021 10:29:05 -0400 Subject: [PATCH 1/3] Fix navigation so it's single top level `ul` with nested further `ul`s --- .../table_of_contents/heading_tree_renderer.rb | 4 ++-- lib/govuk_tech_docs/table_of_contents/helpers.rb | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb b/lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb index 61d0ab27..843775a0 100644 --- a/lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb +++ b/lib/govuk_tech_docs/table_of_contents/heading_tree_renderer.rb @@ -24,7 +24,7 @@ def render_tree(tree, indentation: DEFAULT_INDENTATION, level: nil) end if tree.children.any? && level < @max_level - output += indentation + "\n" unless level.zero? end output diff --git a/lib/govuk_tech_docs/table_of_contents/helpers.rb b/lib/govuk_tech_docs/table_of_contents/helpers.rb index d05e8ed1..cf54b985 100644 --- a/lib/govuk_tech_docs/table_of_contents/helpers.rb +++ b/lib/govuk_tech_docs/table_of_contents/helpers.rb @@ -32,7 +32,8 @@ def render_page_tree(resources, current_page, config, current_page_html) # Sort by weight frontmatter resources = resources .sort_by { |r| [r.data.weight ? 0 : 1, r.data.weight || 0] } - output = ""; + + output = "" + output end end From 9c9c3864c10596ca28b6b79c5dc3659d8a39b816 Mon Sep 17 00:00:00 2001 From: Colin Burn-Murdoch Date: Mon, 28 Jun 2021 10:26:42 -0400 Subject: [PATCH 2/3] Update specs with correct markup. --- .../table_of_contents/helpers.rb | 8 ++-- .../heading_tree_renderer_spec.rb | 42 +++++++++---------- spec/table_of_contents/helpers_spec.rb | 20 ++++----- 3 files changed, 31 insertions(+), 39 deletions(-) diff --git a/lib/govuk_tech_docs/table_of_contents/helpers.rb b/lib/govuk_tech_docs/table_of_contents/helpers.rb index cf54b985..34ca2662 100644 --- a/lib/govuk_tech_docs/table_of_contents/helpers.rb +++ b/lib/govuk_tech_docs/table_of_contents/helpers.rb @@ -32,8 +32,8 @@ def render_page_tree(resources, current_page, config, current_page_html) # Sort by weight frontmatter resources = resources .sort_by { |r| [r.data.weight ? 0 : 1, r.data.weight || 0] } - - output = "\n" output end diff --git a/spec/table_of_contents/heading_tree_renderer_spec.rb b/spec/table_of_contents/heading_tree_renderer_spec.rb index 1405d096..923dc868 100644 --- a/spec/table_of_contents/heading_tree_renderer_spec.rb +++ b/spec/table_of_contents/heading_tree_renderer_spec.rb @@ -22,33 +22,29 @@ } let(:expected_html_with_all_headings) { - <<~EOF - + <<-EOF +
  • + Apples + +
  • +
  • + Oranges +
  • EOF } let(:expected_html_with_max_heading_of_one) { - <<~EOF - + <<-EOF +
  • + Apples +
  • +
  • + Oranges +
  • EOF } diff --git a/spec/table_of_contents/helpers_spec.rb b/spec/table_of_contents/helpers_spec.rb index 6ea8264b..223d95b2 100644 --- a/spec/table_of_contents/helpers_spec.rb +++ b/spec/table_of_contents/helpers_spec.rb @@ -18,7 +18,6 @@ class Subject } expected_single_page_table_of_contents = %{ - - } expect(subject.single_page_table_of_contents(html).strip).to eq(expected_single_page_table_of_contents.strip) @@ -47,7 +45,6 @@ class Subject } expected_single_page_table_of_contents = %{ - } expect(subject.multi_page_table_of_contents(resources, current_page, config, current_page_html).strip).to eq(expected_multi_page_table_of_contents.strip) @@ -197,7 +193,8 @@ def add_children(children) } expected_multi_page_table_of_contents = %{ - + + } expect(subject.multi_page_table_of_contents(resources, current_page, config, current_page_html).strip).to eq(expected_multi_page_table_of_contents.strip) From f38d5634b3833783c9c8be78b6a011a49383a9e9 Mon Sep 17 00:00:00 2001 From: Colin Burn-Murdoch Date: Tue, 13 Jul 2021 08:00:28 -0400 Subject: [PATCH 3/3] Add entry to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae71eab7..ddbaf8ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - [Bump redcarpet to 3.5.1 to fix CVE-2020-26298](https://github.com/alphagov/tech-docs-gem/pull/226) +- [#240: Update menu html structure so it's one single hierarchical list](https://github.com/alphagov/tech-docs-gem/pull/240) ## 2.3.0