Skip to content

Commit a5d0cc8

Browse files
author
Chris Young
committed
doc: prevent displaying empty version picker
Fixes: nodejs#15396
1 parent b8d532c commit a5d0cc8

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

doc/api_assets/style.css

+11
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ em code {
9191

9292
#gtoc li {
9393
display: inline;
94+
border-right: 1px #000 solid;
95+
margin-right: 0.4em;
96+
padding-right: 0.4em;
97+
}
98+
99+
#gtoc li:last-child {
100+
border-right: none;
101+
margin-right: 0;
102+
padding-right: 0;
94103
}
95104

96105
li.version-picker {
@@ -118,6 +127,8 @@ ol.version-picker {
118127

119128
#gtoc ol.version-picker li {
120129
display: block;
130+
border-right: 0;
131+
margin-right: 0;
121132
}
122133

123134
ol.version-picker li a {

doc/template.html

+4-7
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,15 @@ <h1>Node.js __VERSION__ Documentation</h1>
2525
<div id="gtoc">
2626
<ul>
2727
<li>
28-
<a href="index.html" name="toc">Index</a> |
28+
<a href="index.html" name="toc">Index</a>
2929
</li>
3030
<li>
31-
<a href="all.html">View on single page</a> |
31+
<a href="all.html">View on single page</a>
3232
</li>
3333
<li>
34-
<a href="__FILENAME__.json">View as JSON</a> |
35-
</li>
36-
<li class="version-picker">
37-
<a href="#">View another version <span>&#x25bc;</span></a>
38-
__ALTDOCS__
34+
<a href="__FILENAME__.json">View as JSON</a>
3935
</li>
36+
__ALTDOCS__
4037
</ul>
4138
</div>
4239
<hr>

tools/doc/html.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,17 @@ function altDocs(filename) {
232232
return html + '</a></li>';
233233
}
234234

235-
const lis = (vs) => vs.filter(lte).map(li).join('\n');
235+
const lis = versions.filter(lte).map(li).join('\n');
236236

237-
return `<ol class="version-picker">${lis(versions)}</ol>`;
237+
if (!lis.length)
238+
return '';
239+
240+
return `
241+
<li class="version-picker">
242+
<a href="#">View another version <span>&#x25bc;</span></a>
243+
<ol class="version-picker">${lis}</ol>
244+
</li>
245+
`;
238246
}
239247

240248
// handle general body-text replacements

0 commit comments

Comments
 (0)