| 1 |
{#- |
| 2 |
|
| 3 |
Hi there! |
| 4 |
|
| 5 |
You might be interested in https://pradyunsg.me/furo/customisation/sidebar/ |
| 6 |
|
| 7 |
Although if you're reading this, chances are that you're either familiar |
| 8 |
enough with Sphinx that you know what you're doing, or landed here from that |
| 9 |
documentation page. |
| 10 |
|
| 11 |
Hope your day's going well. :) |
| 12 |
|
| 13 |
-#} |
| 14 |
<a class="sidebar-brand{% if logo %} centered{% endif %}" href="{{ pathto(master_doc) }}"> |
| 15 |
{% block brand_content %} |
| 16 |
{%- if logo_url %} |
| 17 |
<div class="sidebar-logo-container"> |
| 18 |
<img class="sidebar-logo" src="{{ logo_url }}" alt="Logo"/> |
| 19 |
</div> |
| 20 |
{%- endif %} |
| 21 |
{%- if theme_light_logo and theme_dark_logo %} |
| 22 |
<div class="sidebar-logo-container"> |
| 23 |
<img class="sidebar-logo only-light" src="{{ pathto('_static/' + theme_light_logo, 1) }}" alt="Light Logo"/> |
| 24 |
<img class="sidebar-logo only-dark" src="{{ pathto('_static/' + theme_dark_logo, 1) }}" alt="Dark Logo"/> |
| 25 |
</div> |
| 26 |
{%- endif %} |
| 27 |
{% if not theme_sidebar_hide_name %} |
| 28 |
<span class="sidebar-brand-text">{{ docstitle if docstitle else project }}</span> |
| 29 |
{%- endif %} |
| 30 |
{% endblock brand_content %} |
| 31 |
<select class="doc-version-switcher" onchange="switchDocs()"> |
| 32 |
<option value="stable">Stable</option> |
| 33 |
<option value="unstable">Unstable</option> |
| 34 |
<!-- Add more versions here as needed --> |
| 35 |
</select> |
| 36 |
</a> |
| 37 |
|
| 38 |
<script> |
| 39 |
// Define the mapping of versions to URLs |
| 40 |
const versionURLs = { |
| 41 |
stable: 'http://docs.bonsaibim.org/', |
| 42 |
unstable: 'http://docs-unstable.bonsaibim.org/', |
| 43 |
// Add more versions here as needed |
| 44 |
}; |
| 45 |
|
| 46 |
// Set the select box value based on the current URL |
| 47 |
document.addEventListener('DOMContentLoaded', (event) => { |
| 48 |
const selectBox = document.querySelector('.doc-version-switcher'); |
| 49 |
const currentURL = window.location.href; |
| 50 |
|
| 51 |
for (const [version, url] of Object.entries(versionURLs)) { |
| 52 |
if (currentURL.includes(url)) { |
| 53 |
selectBox.value = version; |
| 54 |
break; |
| 55 |
} |
| 56 |
} |
| 57 |
}); |
| 58 |
|
| 59 |
function switchDocs() { |
| 60 |
const selectBox = document.querySelector('.doc-version-switcher'); |
| 61 |
const selectedValue = selectBox.value; |
| 62 |
const currentURL = window.location.href; |
| 63 |
|
| 64 |
if (!currentURL.includes(versionURLs[selectedValue])) { |
| 65 |
window.location.href = versionURLs[selectedValue]; |
| 66 |
} |
| 67 |
} |
| 68 |
</script> |