Skip to content

Commit 2b08ab9

Browse files
docs: added versions page
risk: low
1 parent de1aa3c commit 2b08ab9

File tree

3 files changed

+137
-2
lines changed

3 files changed

+137
-2
lines changed

docs/content/en/versions/_index.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
---
2-
title: "Release Notes and Upgrade Guides"
2+
itle: "Python SDK Archive"
33
linkTitle: "Versions"
44
toc_hide: true
5+
versionPicker: false
6+
sectionIndex: falsex
7+
cascade:
8+
- type: "docs"
9+
toc_root: true
10+
_target:
11+
path: "/*/**"
512
---
6-
Here you can find all available releases.
13+
14+
This page contains the latest versions of the Python SDK documentation.
15+
16+
{{< versions-archive >}}
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{{/* (C) 2023 GoodData Corporation */}}
2+
{{/* Static versions archive table - generated by Hugo at build time */}}
3+
4+
{{ if .Site.Params.versions }}
5+
6+
{{ $allVersions := .Site.Params.versions }}
7+
{{ $changelogPageURL := "https://github.com/gooddata/gooddata-python-sdk/releases/tag/v" }}
8+
9+
{{ if $allVersions }}
10+
<div id="versions-container">
11+
<!-- Non-dev versions table -->
12+
<div class="table-responsive">
13+
<p>Latest versions</p>
14+
<table class="table table-striped table-hover" id="versions-table">
15+
<thead class="table-dark">
16+
<tr>
17+
<th scope="col">Version</th>
18+
<th scope="col">Documentation</th>
19+
<th scope="col">Changelog</th>
20+
</tr>
21+
</thead>
22+
<tbody id="versions-tbody">
23+
{{ range $allVersions }}
24+
{{ if not (eq .version "dev") }}
25+
<tr>
26+
<td><strong>{{ .version }}</strong></td>
27+
<td>
28+
<a href="{{ .url }}" aria-label="View documentation for version {{ .version }}">
29+
<i class="fas fa-book me-1" aria-hidden="true"></i>View Documentation
30+
</a>
31+
</td>
32+
<td>
33+
{{ if .changelog}}
34+
<a href="{{ .changelog }}" aria-label="View changelog for version {{ .version }}">
35+
<i class="fas fa-book me-1" aria-hidden="true"></i>View Changelog
36+
</a>
37+
{{ else }}
38+
{{ $versionParts := split .version "." }}
39+
{{ $formattedVersion := .version }}
40+
{{ if eq (len $versionParts) 2 }}
41+
{{ $formattedVersion = printf "%s.0" .version }}
42+
{{ end }}
43+
<a href="{{ $changelogPageURL }}{{ $formattedVersion }}" aria-label="View changelog for version {{ .version }}">
44+
<i class="fas fa-book me-1" aria-hidden="true"></i>View Changelog
45+
</a>
46+
{{ end }}
47+
</td>
48+
</tr>
49+
{{ end }}
50+
{{ end }}
51+
</tbody>
52+
</table>
53+
</div>
54+
<!-- Dev version table -->
55+
<div class="table-responsive">
56+
<p>Versions in active development</p>
57+
<table class="table table-striped table-hover" id="dev-versions-table">
58+
<thead class="table-dark">
59+
<tr>
60+
<th scope="col">Version</th>
61+
<th scope="col">Documentation</th>
62+
</tr>
63+
</thead>
64+
<tbody id="dev-versions-tbody">
65+
{{ range $allVersions }}
66+
{{ if eq .version "dev" }}
67+
<tr>
68+
<td><strong>{{ .version }}</strong></td>
69+
<td>
70+
<a href="{{ .url }}" aria-label="View documentation for version {{ .version }}">
71+
<i class="fas fa-book me-1" aria-hidden="true"></i>View Documentation
72+
</a>
73+
</td>
74+
</tr>
75+
{{ end }}
76+
{{ end }}
77+
</tbody>
78+
</table>
79+
</div>
80+
</div>
81+
{{ else }}
82+
<div class="alert alert-warning" role="alert">
83+
<h4>No Versions Available</h4>
84+
<p>No documentation versions are currently available for display.</p>
85+
</div>
86+
{{ end }}
87+
{{ end }}

docs/static/js/archive-link.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
document.addEventListener('DOMContentLoaded', function () {
2+
function createArchiveLink() {
3+
const link = document.createElement('a');
4+
link.className = 'dropdown-item';
5+
6+
const currentHostname = window.location.hostname;
7+
if (currentHostname.includes('netlify.app')) {
8+
// For Netlify previews, link to the versions page within the current preview site
9+
link.href = window.location.origin + '/docs/python-sdk/versions/';
10+
} else if (currentHostname === 'localhost' || currentHostname === '127.0.0.1') {
11+
// For local testing, link to the versions page
12+
link.href = '/versions/';
13+
} else {
14+
// For production - link to the unversioned archive page
15+
link.href = 'https://www.gooddata.com/docs/python-sdk/versions/';
16+
}
17+
18+
// Safe DOM manipulation - XSS protected
19+
const icon = document.createElement('i');
20+
icon.className = 'fas fa-archive me-2';
21+
icon.setAttribute('aria-hidden', 'true');
22+
23+
link.appendChild(icon);
24+
link.appendChild(document.createTextNode('Archive'));
25+
26+
// Add descriptive text for screen readers
27+
link.setAttribute('aria-label', 'View all versions in archive');
28+
29+
return link;
30+
}
31+
32+
// Select the dropdown menu and add the archive link
33+
const dropdownMenus = document.getElementsByClassName('dropdown-menu');
34+
for (let i = 0; i < dropdownMenus.length; i++) {
35+
const archiveLink = createArchiveLink();
36+
dropdownMenus[i].appendChild(archiveLink);
37+
}
38+
});

0 commit comments

Comments
 (0)