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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b52d6e8aa198588eb1483b68997af30d2ead1179addc62110cfdab7d1d117920
|
4
|
+
data.tar.gz: ae9fb52fb1ca0929cc5be15f74ca32d6acd159eb248f397b976f963d8a00ca76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
@@ -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
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
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
|
-
|
80
|
+
list_items_from_headings(
|
73
81
|
content,
|
74
82
|
url: resource.url,
|
75
83
|
max_level: config[:tech_docs][:max_toc_heading_level],
|
@@ -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
|
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.
|
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-
|
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
|