Skip to content

Commit

Permalink
Merge pull request #6464 from wazuh/4.5.3-theme-minor-fixes
Browse files Browse the repository at this point in the history
[4.5.3] Fixed first link of the navigation bar "On this page" when using docutils>=0.17
  • Loading branch information
javimed authored Sep 11, 2023
2 parents a440df5 + b739ee2 commit d9111ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@
*/

/* Fix for the first item when using the Bootstrap scrollspy in our documentation */
if ( $('#local-toc').length > 0 ) {
/* Fix the href of the first item */
const firstLocalTocItem = $('#local-toc > .navbar-nav > .nav-item:first-of-type > .nav-link');
const firstSection = $('main:first-of-type > .section:first-of-type');
firstLocalTocItem.attr('href', firstLocalTocItem.attr('href') + firstSection.attr('id'));
}
$(document).ready(function() {
if ($('#local-toc').length > 0) {
/* Fix the href of the first item */
const firstLocalTocItem = $('#local-toc > .navbar-nav > .nav-item:first-of-type > .nav-link');
let firstSection = $('main:first-of-type > .section:first-of-type');

/* Fix for docutils>=0.17 */
if (firstSection.length === 0) {
firstSection = $('main:first-of-type > section:first-of-type');
}

// Check if the firstSection has a valid id before updating the href
const firstSectionId = firstSection.attr('id');
if (firstSectionId) {
firstLocalTocItem.attr('href', firstLocalTocItem.attr('href') + firstSectionId);
}
}
});

/* Expand accordion functionality for the local-toc */
$('#local-toc .nav-link').on('click', function(e) {
Expand Down
Loading

0 comments on commit d9111ab

Please sign in to comment.