Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
docs: add versions panel
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Matyushentsev authored and Alexander Matyushentsev committed Jan 2, 2021
1 parent 024b3b3 commit 3397d9f
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/assets/versions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.rst-other-versions {
text-align: right;
}

.rst-other-versions > dl, .rst-other-versions dt, .rst-other-versions small {
display: none;
}

.rst-other-versions > dl:first-child {
display: block;
}

.rst-versions.shift-up .rst-other-versions {
display: block;
}

.rst-versions .rst-other-versions {
display: none;
}
22 changes: 22 additions & 0 deletions docs/assets/versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function callback(response) {
const div = document.createElement('div');
div.innerHTML = response.html;
document.body.appendChild(div);
const container = div.querySelector('.rst-versions');
div.querySelector('.rst-current-version').addEventListener('click', function() {
const classes = container.className.split(' ');
const index = classes.indexOf('shift-up');
if (index === -1) {
classes.push('shift-up');
} else {
classes.splice(index, 1);
}
container.className = classes.join(' ');
});
}

var script = document.createElement('script');
script.src = 'https://argocd-notifications.readthedocs.io/_/api/v2/footer_html/?'+
'callback=callback&project=argocd-notifications&page=&theme=mkdocs&format=jsonp&docroot=docs&source_suffix=.md&version=' + (window['READTHEDOCS_DATA'] || { version: 'latest' }).version;

document.getElementsByTagName('head')[0].appendChild(script);
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ theme:
font:
text: 'Work Sans'
logo: 'assets/logo.png'
extra_javascript:
- assets/versions.js
extra_css:
- assets/versions.css
markdown_extensions:
- codehilite
- admonition
Expand Down

0 comments on commit 3397d9f

Please sign in to comment.