Spaces:
Running
Running
File size: 1,449 Bytes
546720a 667244c 546720a 9f8a30b 546720a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
// Generate navigation items
const sections = [
{ id: 'endpoints', title: 'Endpoints' },
{ id: 'register', title: 'Register' },
{ id: 'login', title: 'Login' },
{ id: 'refresh', title: 'Refresh Token' },
{ id: 'generate', title: 'Generate' },
{ id: 'workflow', title: 'Workflow Example' }
];
const navItems = document.querySelector('.nav-items');
sections.forEach(section => {
const item = document.createElement('div');
item.className = 'nav-item';
item.textContent = section.title;
item.setAttribute('data-section', section.id);
item.addEventListener('click', () => {
document.getElementById(section.id).scrollIntoView({ behavior: 'smooth' });
});
navItems.appendChild(item);
});
// Highlight current section in navigation
const observerCallback = (entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const currentNav = document.querySelector(`.nav-item[data-section="${entry.target.id}"]`);
if (currentNav) {
document.querySelectorAll('.nav-item').forEach(item => {
item.style.backgroundColor = '';
});
currentNav.style.backgroundColor = '#f3f4f6';
}
}
});
};
const observer = new IntersectionObserver(observerCallback, {
threshold: 0.2
});
document.querySelectorAll('section').forEach(section => {
observer.observe(section);
}); |