syncopated-ops / script.js
b08x's picture
This is a crucial correction. You want the **Nextra Documentation Layout** (the structure) combined with the **Tactical Ops Color Palette & Font** (the skin), but **without** the "roleplay" elements (no "SYSTEM ONLINE" widgets, no dense data grids, no radar charts, no forced uppercase).
2d1d74f verified
document.addEventListener('DOMContentLoaded', () => {
// Highlight TOC and Sidebar based on scroll position
const mainContent = document.getElementById('main-content');
const sections = document.querySelectorAll('section[id]');
// Sidebar Link Logic
const sidebarLinks = document.querySelectorAll('.sidebar-link');
const currentUrl = window.location.pathname;
sidebarLinks.forEach(link => {
// Simple check for demo purposes
if(link.getAttribute('href') === currentUrl || (currentUrl === '/' && link.getAttribute('href') === '/index.html')) {
link.classList.add('nav-item-active', 'font-medium');
link.classList.remove('text-muted', 'hover:text-primary');
}
});
// Intersection Observer for TOC
const observerOptions = {
root: mainContent,
rootMargin: '-20% 0px -70% 0px', // Trigger when section is near top
threshold: 0
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const id = entry.target.getAttribute('id');
// Update TOC
document.querySelectorAll('.toc-link').forEach(link => {
link.classList.remove('toc-item-active', 'font-medium');
link.classList.add('text-muted');
if (link.getAttribute('href') === `#${id}`) {
link.classList.add('toc-item-active', 'font-medium');
link.classList.remove('text-muted');
}
});
}
});
}, observerOptions);
sections.forEach(section => observer.observe(section));
});