Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v6.x backport] doc: add links to alternative versions of doc #15670

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
doc: prevent displaying empty version picker
PR-URL: #15420
Fixes: #15396
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Chris Young committed Sep 29, 2017
commit 7cd60e0abddb21ea1874cb451c0d4534ce0f856e
12 changes: 12 additions & 0 deletions doc/api_assets/style.css
Original file line number Diff line number Diff line change
@@ -91,6 +91,15 @@ em code {

#gtoc li {
display: inline;
border-right: 1px #000 solid;
margin-right: 0.4em;
padding-right: 0.4em;
}

#gtoc li:last-child {
border-right: none;
margin-right: 0;
padding-right: 0;
}

li.version-picker {
@@ -118,6 +127,9 @@ ol.version-picker {

#gtoc ol.version-picker li {
display: block;
border-right: 0;
margin-right: 0;
width: 100%;
}

ol.version-picker li a {
11 changes: 4 additions & 7 deletions doc/template.html
Original file line number Diff line number Diff line change
@@ -25,18 +25,15 @@ <h1>Node.js __VERSION__ Documentation</h1>
<div id="gtoc">
<ul>
<li>
<a href="index.html" name="toc">Index</a> |
<a href="index.html" name="toc">Index</a>
</li>
<li>
<a href="all.html">View on single page</a> |
<a href="all.html">View on single page</a>
</li>
<li>
<a href="__FILENAME__.json">View as JSON</a> |
</li>
<li class="version-picker">
<a href="#">View another version <span>&#x25bc;</span></a>
__ALTDOCS__
<a href="__FILENAME__.json">View as JSON</a>
</li>
__ALTDOCS__
</ul>
</div>
<hr>
13 changes: 10 additions & 3 deletions tools/doc/html.js
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ var gtocPath = path.resolve(path.join(
var gtocLoading = null;
var gtocData = null;
var docCreated = null;
var nodeVersion = null;

/**
* opts: input, filename, template, nodeVersion.
@@ -211,9 +210,17 @@ function altDocs(filename) {
return html + '</a></li>';
}

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

return `<ol class="version-picker">${lis(versions)}</ol>`;
if (!lis.length)
return '';

return `
<li class="version-picker">
<a href="#">View another version <span>&#x25bc;</span></a>
<ol class="version-picker">${lis}</ol>
</li>
`;
}

// handle general body-text replacements