Skip to content

Commit 39a54ee

Browse files
committed
Fix 404 page (missing tabs property was making it render funny).
Also added code to detect if the 404 is on a documentation page. The version switcher in the documentation attempts to preserve the path (so that if you are looking at, say, JobExecutor in a version, you'd also potentially be looking at JobExecutor after the switch). However, there is no guarantee that the docs structure is the same in the two versions, so you may land on a page that's not there. The code looks at whether you are hitting a 404 on a docs page and offers a link to the main docs page for that version. Also, a minor fix in `getCurrentVersion`
1 parent 681a6c1 commit 39a54ee

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

web/404.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
---
22
permalink: /404.html
33
layout: default
4+
tab: 100
45
---
56

67
<div class="container">
7-
<h1>404</h1>
8+
<div v-if="isDocsPage()">
9+
<h1>404</h1>
10+
<p><strong>Page not found</strong></p>
11+
<p>This version of the documentation does not contain this page. Please go to the <a :href="getMainDocsPage()">main documentation page</a>.
12+
</div>
13+
<div v-else>
814

9-
<p><strong>Page not found :(</strong></p>
10-
<p>The requested page could not be found.</p>
15+
<h1>404</h1>
16+
17+
<p><strong>Page not found</strong></p>
18+
<p>The requested page could not be found.</p>
19+
</div>
1120
</div>

web/_includes/vueinit.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
},
1010
methods: {
1111
getSortedVersionLabels: getSortedVersionLabels,
12-
setVersion: setVersion
12+
setVersion: setVersion,
13+
getMainDocsPage: getMainDocsPage,
14+
isDocsPage: isDocsPage
1315
}
1416
});
1517

web/versioning.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function setVersion() {
219219
* currently displayed documentation version.
220220
*/
221221
function getCurrentVersion() {
222-
v = splitLocation()[1];
222+
var v = splitLocation()[1];
223223
if (v == "") {
224224
return v;
225225
}
@@ -228,4 +228,22 @@ function getCurrentVersion() {
228228
}
229229
}
230230

231+
/**
232+
* Returns the main documentation page for the current version by removing
233+
* everything after <code>"../docs/v/x.y.z/"</code> from the current URL.
234+
*/
235+
function getMainDocsPage() {
236+
var s = splitLocation();
237+
238+
return s[0] + "/" + s[1] + "/";
239+
}
240+
241+
/**
242+
* Returns true if the current URL points to a versioned documentation
243+
* page.
244+
*/
245+
function isDocsPage() {
246+
return window.location.href.includes("/docs/v/");
247+
}
248+
231249
initVersions();

0 commit comments

Comments
 (0)