Skip to content

Commit

Permalink
Add version dropdown to landing page
Browse files Browse the repository at this point in the history
- Updated v1.0 to match
  • Loading branch information
bparks13 committed Jan 14, 2025
1 parent 43fac27 commit 26f6fdf
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
37 changes: 37 additions & 0 deletions source/_static/sphinx_versioning_plugin/v1.0/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,43 @@
spellcheck="false"/>
<span class="search-button__kbd-shortcut"><kbd class="kbd-shortcut__modifier">Ctrl</kbd>+<kbd>K</kbd></span>
</form></div>
<div class="sidebar-primary-item"><div id="sphinx_versioning_container">
<span style="vertical-align: middle">Versions</span>
<select
style="vertical-align: middle; margin-left: 5px"
onchange="window.location.href=this.value"
id="sphinx_versioning_dropdown_menu"
>
<option value="/">Latest</option>
<!-- Additional versions will be populated here by JavaScript -->
</select>
</div>
<script>
fetch('/_static/sphinx_versioning_plugin/versions.json')
.then((response) => response.json())
.then((versions) => {
const dropdown = document.getElementById('sphinx_versioning_dropdown_menu');
const container = document.getElementById('sphinx_versioning_container');

// Check if the versions array is empty
if (versions.length === 0) {
// Hide the entire container if there are no versions
container.style.display = 'none';
} else {
versions.forEach((version) => {
const option = document.createElement('option');
option.value = `/_static/sphinx_versioning_plugin/${version}/`;
option.text = version;

// If current page URL contains this version, set it as selected
if (window.location.pathname.includes(`_static/sphinx_versioning_plugin/${version}/`)) {
option.selected = true;
}
dropdown.appendChild(option);
});
}
});
</script></div>
</div>


Expand Down
5 changes: 4 additions & 1 deletion source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@
html_style = "_static/theme_overrides.css"

html_sidebars = {
'index': ['search-field.html'],
'index': [
'search-field.html',
'sidebar/sphinx_versioning.html'
],
"**": [
"sidebar-nav-bs.html",
'sidebar/sphinx_versioning.html',
Expand Down

0 comments on commit 26f6fdf

Please sign in to comment.