Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed function for first nav item of sidebar-right #6457

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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