diff --git a/src/resources/views/layouts/knowledge-base.blade.php b/src/resources/views/layouts/knowledge-base.blade.php index 43d3e1c..5f4a915 100644 --- a/src/resources/views/layouts/knowledge-base.blade.php +++ b/src/resources/views/layouts/knowledge-base.blade.php @@ -285,18 +285,37 @@ function restoreSidebarScroll() { // Highlight current document in sidebar function highlightCurrentDocument() { const sidebar = document.getElementById('kb-sidebar'); - if (!sidebar) return; + if (!sidebar) { + console.log('Sidebar not found for highlighting'); + return; + } const currentPath = window.location.pathname; const links = sidebar.querySelectorAll('a'); + console.log('Current path:', currentPath); + console.log('Found links in sidebar:', links.length); + links.forEach(link => { - if (link.getAttribute('href') === currentPath) { + const href = link.getAttribute('href'); + + // Remove previous highlighting + link.classList.remove('bg-indigo-50', 'text-indigo-700', 'font-semibold'); + link.classList.add('text-gray-700'); + + const icon = link.querySelector('svg'); + if (icon) { + icon.classList.remove('text-indigo-600'); + icon.classList.add('text-gray-400', 'group-hover:text-gray-600'); + } + + // Check if this is the current page + if (href === currentPath || href === window.location.href || + (href && currentPath && href.endsWith(currentPath))) { + console.log('Matched link:', href, 'with current path:', currentPath); link.classList.add('bg-indigo-50', 'text-indigo-700', 'font-semibold'); - link.classList.remove('text-gray-700', 'hover:bg-gray-100'); + link.classList.remove('text-gray-700'); - // Update icon color - const icon = link.querySelector('svg'); if (icon) { icon.classList.remove('text-gray-400', 'group-hover:text-gray-600'); icon.classList.add('text-indigo-600');