Skip to content

Commit 96b5fce

Browse files
authored
Merge pull request #658 from quanb-duy/404-message
DP-2808 - 404 message for older versions
2 parents 09ec236 + d02f02b commit 96b5fce

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

docs/layouts/404.html

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{{ define "main" -}}
2+
<div class="row default-404">
3+
<div class="container">
4+
<div class="row">
5+
<div class="col-12 col-lg-6">
6+
<h2 class="mt-0">404 Page</h2>
7+
<h1>Ohh, there is nothing in here!</h1>
8+
9+
{{ if and (isset .Site.Params "404") (isset (index .Site.Params "404") "links") }}
10+
<div class="mt-7">
11+
<h2 class="mb-4">But you can try:</h2>
12+
<ul class="mt-2">
13+
{{ range index (index .Site.Params "404") "links" }}
14+
<li>
15+
<a href="{{ .link }}">{{ .title }}</a>
16+
</li>
17+
{{ end }}
18+
</ul>
19+
</div>
20+
{{ end }}
21+
</div>
22+
<div class="col-12 col-lg-6 d-flex align-items-center justify-content-end">
23+
<img class="mw-100" src="https://www.gooddata.com/img/pages/error/error-404_animation.svg" alt="Where did it go?">
24+
</div>
25+
</div>
26+
</div>
27+
</div>
28+
29+
<div class="row old-version__404 d-none">
30+
<div class="container">
31+
<div class="row">
32+
<div class="col-12 col-lg-6">
33+
<h2 class="mt-0">404 Page</h2>
34+
<h1>This version is no longer live</h1>
35+
36+
{{ if and (isset .Site.Params "404") (isset (index .Site.Params "404") "links") }}
37+
<div class="mt-7">
38+
<h2 class="mb-4">But you can try:</h2>
39+
<a href="https://gooddata.com/docs/python-sdk/latest/">Latest version of Python SDK</a>
40+
<p>You can find past versions of the documentation in the Python SDK <a href="https://github.com/gooddata/gooddata-python-sdk">GitHub repository</a>. To retrieve older version, follow the instructions in the <a href="https://github.com/gooddata/gooddata-python-sdk/blob/master/CONTRIBUTING.md">README</a>.</p>
41+
</div>
42+
{{ end }}
43+
44+
</div>
45+
<div class="col-12 col-lg-6 d-flex align-items-center justify-content-end">
46+
<img class="mw-100" src="https://www.gooddata.com/img/pages/error/error-404_animation.svg" alt="Where did it go?">
47+
</div>
48+
</div>
49+
</div>
50+
</div>
51+
{{- end }}

docs/layouts/partials/hooks/body-end.html

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
<script src="/js/code-select.js"></script>
55
<script src="/js/content-select.js"></script>
66
<script src="/js/pactsafe.js"></script>
7+
<script src="/js/404-old-version.js"></script>
8+

docs/static/js/404-old-version.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$(document).ready(function () {
2+
const defaultError = document.querySelector(".default-404");
3+
const newError = document.querySelector(".old-version__404");
4+
const dropdownItems = document.getElementsByClassName("dropdown-item");
5+
const availableVersions = ["latest"];
6+
7+
// put each available version into array availableVersions
8+
[...dropdownItems].forEach((element) => {
9+
availableVersions.push(element.innerText.trim());
10+
});
11+
12+
if (window.location) {
13+
// pathname of the current page
14+
const pathname = window.location.pathname;
15+
16+
// extract version from pathname
17+
const version = pathname.split('/')[1];
18+
19+
// Check if the version extracted is a valid version, if it is included in available versions and if it matches the regex digit format
20+
if (version && !availableVersions.includes(version) && version.match(/^\d+\.\d+$/)) {
21+
newError.classList.toggle("d-none");
22+
defaultError.classList.toggle("d-none");
23+
}
24+
}
25+
26+
});

0 commit comments

Comments
 (0)