smol fix to nav bar
This commit is contained in:
parent
17da6d4ada
commit
9e8dc9f84a
@ -59,7 +59,8 @@ export default defineConfig({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add navigation to regular docs pages
|
// Add navigation to regular docs pages
|
||||||
setTimeout(() => {
|
// Add navigation to docs pages with retry logic
|
||||||
|
function addNavigation(retries = 0) {
|
||||||
const currentPath = window.location.pathname;
|
const currentPath = window.location.pathname;
|
||||||
|
|
||||||
// Skip if page has its own navigation
|
// Skip if page has its own navigation
|
||||||
@ -76,34 +77,49 @@ export default defineConfig({
|
|||||||
const searchContainer = header.querySelector('[class*="search"]')?.parentElement;
|
const searchContainer = header.querySelector('[class*="search"]')?.parentElement;
|
||||||
const targetContainer = searchContainer || header.querySelector('.sl-flex') || header;
|
const targetContainer = searchContainer || header.querySelector('.sl-flex') || header;
|
||||||
|
|
||||||
// Create navigation container
|
if (targetContainer) {
|
||||||
const nav = document.createElement('nav');
|
// Create navigation container
|
||||||
nav.className = 'custom-nav-links';
|
const nav = document.createElement('nav');
|
||||||
nav.setAttribute('aria-label', 'Product Navigation');
|
nav.className = 'custom-nav-links';
|
||||||
|
nav.setAttribute('aria-label', 'Product Navigation');
|
||||||
|
|
||||||
// Create links from configuration
|
// Create links from configuration
|
||||||
JAN_NAV_CONFIG.links.forEach(link => {
|
JAN_NAV_CONFIG.links.forEach(link => {
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = link.href;
|
a.href = link.href;
|
||||||
a.textContent = link.text;
|
a.textContent = link.text;
|
||||||
a.className = 'nav-link';
|
a.className = 'nav-link';
|
||||||
|
|
||||||
// Set active state
|
// Set active state
|
||||||
if (link.isActive(currentPath)) {
|
if (link.isActive(currentPath)) {
|
||||||
a.setAttribute('aria-current', 'page');
|
a.setAttribute('aria-current', 'page');
|
||||||
|
}
|
||||||
|
|
||||||
|
nav.appendChild(a);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Insert navigation in the optimal position
|
||||||
|
if (searchContainer) {
|
||||||
|
targetContainer.insertBefore(nav, searchContainer);
|
||||||
|
} else {
|
||||||
|
targetContainer.appendChild(nav);
|
||||||
}
|
}
|
||||||
|
} else if (retries < 3) {
|
||||||
nav.appendChild(a);
|
// Retry if container not found yet
|
||||||
});
|
setTimeout(() => addNavigation(retries + 1), 200);
|
||||||
|
|
||||||
// Insert navigation in the optimal position
|
|
||||||
if (searchContainer) {
|
|
||||||
targetContainer.insertBefore(nav, searchContainer);
|
|
||||||
} else {
|
|
||||||
targetContainer.appendChild(nav);
|
|
||||||
}
|
}
|
||||||
|
} else if (retries < 3) {
|
||||||
|
// Retry if header/title not found yet
|
||||||
|
setTimeout(() => addNavigation(retries + 1), 200);
|
||||||
}
|
}
|
||||||
}, 100);
|
}
|
||||||
|
|
||||||
|
// Start navigation injection
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
setTimeout(() => addNavigation(), 100);
|
||||||
|
} else {
|
||||||
|
addNavigation();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user