Skip to content
Merged
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
21 changes: 21 additions & 0 deletions layouts/partials/docs-nav.html
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,27 @@
const sidebar = document.getElementById('sidebar');
const footer = document.querySelector('footer');

// Scroll sidebar to show active page on load
const activeLink = sidebar.querySelector('a.active');
if (activeLink) {
// Find the scrollable UL container that contains the active link
const scrollContainer = activeLink.closest('ul.overflow-y-auto');

if (scrollContainer) {
// Get the position of the active link relative to its scrollable container
const linkRect = activeLink.getBoundingClientRect();
const containerRect = scrollContainer.getBoundingClientRect();

// Calculate how far the link is from the top of the container
const relativeTop = linkRect.top - containerRect.top + scrollContainer.scrollTop;

// Scroll so the active link appears near the top (with some padding)
const scrollPosition = relativeTop - 20; // 20px padding from top

scrollContainer.scrollTop = Math.max(0, scrollPosition);
}
}

window.addEventListener('scroll', function() {
const scrolledHeight = window.scrollY + window.innerHeight;
if (scrolledHeight >= footer.offsetTop) {
Expand Down