Skip to content

Commit

Permalink
DBZ-8483 Improve documentation version picker
Browse files Browse the repository at this point in the history
  • Loading branch information
Naros committed Jan 21, 2025
1 parent 8cf2884 commit 5d726ed
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions _antora/supplemental_ui/partials/page-versions.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,35 @@
<button class="version-menu-toggle versions-menu-current" title="Show other versions of page">{{page.componentVersion.displayVersion}}</button>
<div class="version-menu">
{{#each page.versions}}
<a class="version
{{~#if (eq ./version @root.page.version)}} is-current{{/if~}}
{{~#if ./missing}} is-missing{{/if}}" href="/documentation/reference/{{./displayVersion}}/index.html">{{./displayVersion}}</a>
{{#if ./missing}}
<a class="version is-missing" href="#">{{./displayVersion}}</a>
{{else}}
{{#if (eq ./version @root.page.version)}}
<a class="version is-current" href="{{this.url}}" data-hash="true">{{./displayVersion}}</a>
{{else}}
<a class="version" href="/documentation/{{this.url}}" data-hash="true">{{./displayVersion}}</a>
{{/if}}
{{/if}}
{{/each}}
</div>
|
</div>
</div>
<script>
function updateAnchorsWithHash() {
const currentHash = window.location.hash;
if (currentHash) {
document.querySelectorAll('a[data-hash="true"]').forEach(link => {
const baseHref = link.getAttribute('href').split('#')[0];
link.setAttribute('href', baseHref + currentHash);
});
}
}
// Listen for hashchange and update anchors
window.addEventListener('hashchange', updateAnchorsWithHash);
// Update anchors on initial load
document.addEventListener('DOMContentLoaded', updateAnchorsWithHash);
</script>
{{/if}}

0 comments on commit 5d726ed

Please sign in to comment.