govuk_tech_docs 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of govuk_tech_docs might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80dfd8a946033705eb3157cb70319a30860ca096e85ec4e8cf47a04b5c001d38
4
- data.tar.gz: 553772f54e1b4afbd0db8c3eb40d60460df35104b570b8be13c527cecf71ff54
3
+ metadata.gz: b52d6e8aa198588eb1483b68997af30d2ead1179addc62110cfdab7d1d117920
4
+ data.tar.gz: ae9fb52fb1ca0929cc5be15f74ca32d6acd159eb248f397b976f963d8a00ca76
5
5
  SHA512:
6
- metadata.gz: d35acab5b3b497aa48fe880e838b817d584a6545b5881ef5f9ceeee40030366e15a4b183fa409b647b3ab4f64a81d478584787e68cf62d97e84be32a26c24802
7
- data.tar.gz: 3f495169c4f98cf79f69ee8a33ff3440908a861fcd3ff2aa823f000dda28cfc2da0f5559c22851cbd4a456eb560b50f5af06598212b5c5a08be8ea72aa948022
6
+ metadata.gz: f0b288f32a3adf1c974d525186efd8839b71372eed7425a1e31dc13f6a27b840e00536d481dca6218d303bdfea281299672b409080a53ab40c7b483968cfda84
7
+ data.tar.gz: 18de4113f809ff2c8ef69f399d20e0781241242eaf0660cd2668d023d3e136114abada7e783087b4bf8e19149c4d1ba570fe161fb7798ec33ff49e8bbc1de6dc
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.4.2
6
+
7
+ - [#251 Fix missing `<ul>` in single page navigation](https://github.com/alphagov/tech-docs-gem/pull/251)
8
+
5
9
  ## 2.4.1
6
10
 
7
11
  - [#248: Remove IE8 fallback PNG with broken image reference](https://github.com/alphagov/tech-docs-gem/pull/248)
@@ -13,6 +13,7 @@ header_links:
13
13
  Expired page: /expired-page.html
14
14
  Expired with owner: /expired-page-with-owner.html
15
15
  Not expired page: /not-expired-page.html
16
+ Single page nav: /single-page-nav.html
16
17
 
17
18
  footer_links:
18
19
  Accessibility: /hidden-page.html
@@ -0,0 +1,13 @@
1
+ ---
2
+ layout: layout
3
+ multipage_nav: false
4
+ hide_in_navigation: true
5
+ ---
6
+
7
+ # A page that does not use multi-page navigation
8
+
9
+ ## A subheader
10
+
11
+ ### A h3 subheader
12
+
13
+ ## Another subheader
@@ -8,14 +8,11 @@ module GovukTechDocs
8
8
  module TableOfContents
9
9
  module Helpers
10
10
  def single_page_table_of_contents(html, url: "", max_level: nil)
11
- headings = HeadingsBuilder.new(html, url).headings
12
-
13
- if headings.none? { |heading| heading.size == 1 }
14
- raise "No H1 tag found. You have to at least add one H1 heading to the page: " + url
15
- end
11
+ output = "<ul>\n"
12
+ output += list_items_from_headings(html, url: url, max_level: max_level)
13
+ output += "</ul>\n"
16
14
 
17
- tree = HeadingTreeBuilder.new(headings).tree
18
- HeadingTreeRenderer.new(tree, max_level: max_level).html
15
+ output
19
16
  end
20
17
 
21
18
  def multi_page_table_of_contents(resources, current_page, config, current_page_html = nil)
@@ -28,6 +25,17 @@ module GovukTechDocs
28
25
  render_page_tree(resources, current_page, config, current_page_html)
29
26
  end
30
27
 
28
+ def list_items_from_headings(html, url: "", max_level: nil)
29
+ headings = HeadingsBuilder.new(html, url).headings
30
+
31
+ if headings.none? { |heading| heading.size == 1 }
32
+ raise "No H1 tag found. You have to at least add one H1 heading to the page: " + url
33
+ end
34
+
35
+ tree = HeadingTreeBuilder.new(headings).tree
36
+ HeadingTreeRenderer.new(tree, max_level: max_level).html
37
+ end
38
+
31
39
  def render_page_tree(resources, current_page, config, current_page_html)
32
40
  # Sort by weight frontmatter
33
41
  resources = resources
@@ -69,7 +77,7 @@ module GovukTechDocs
69
77
  output += "</li>\n"
70
78
  else
71
79
  output +=
72
- single_page_table_of_contents(
80
+ list_items_from_headings(
73
81
  content,
74
82
  url: resource.url,
75
83
  max_level: config[:tech_docs][:max_toc_heading_level],
@@ -1,3 +1,3 @@
1
1
  module GovukTechDocs
2
- VERSION = "2.4.1".freeze
2
+ VERSION = "2.4.2".freeze
3
3
  end
@@ -4,8 +4,10 @@ wrap_layout :core do
4
4
 
5
5
  content_for(:toc_module, "in-page-navigation")
6
6
 
7
+ use_multipage_nav = current_page.data.fetch(:multipage_nav, config[:tech_docs][:multipage_nav])
8
+
7
9
  content_for :sidebar do
8
- if config[:tech_docs][:multipage_nav] %>
10
+ if use_multipage_nav %>
9
11
  <%= multi_page_table_of_contents(sitemap.resources, current_page, config, html) %>
10
12
  <% else %>
11
13
  <%= single_page_table_of_contents(html, max_level: config[:tech_docs][:max_toc_heading_level]) %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_tech_docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Government Digital Service
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-28 00:00:00.000000000 Z
11
+ date: 2021-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: autoprefixer-rails
@@ -309,6 +309,7 @@ files:
309
309
  - example/source/not-expired-page.html.md
310
310
  - example/source/pets.yml
311
311
  - example/source/prevent-index-page.html.md
312
+ - example/source/single-page-nav.html.md
312
313
  - example/source/stylesheets/print.css.scss
313
314
  - example/source/stylesheets/screen-old-ie.css.scss
314
315
  - example/source/stylesheets/screen.css.scss