Skip to content

Commit e21756c

Browse files
committed
feat: add contextual sub-navbar for CPU pages
1 parent 88853ee commit e21756c

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

js/script.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,36 @@ const injectCommonElements = () => {
305305
const navElement = document.getElementById('navbar-placeholder');
306306
const footerElement = document.getElementById('footer-placeholder');
307307

308-
if (navElement) navElement.innerHTML = navbarHTML;
308+
if (navElement) {
309+
navElement.innerHTML = navbarHTML;
310+
311+
// --- CPU Contextual Sub-Navbar ---
312+
const cpuPages = [
313+
'cpu.html', 'cpu-overview.html', 'cpu-history.html', 'cpu-architecture.html',
314+
'cpu-core.html', 'cpu-cache.html', 'cpu-fabrication.html', 'cpu-database.html',
315+
'intel-cpu-history.html', 'amd-cpu-history.html', 'apple-silicon-history.html',
316+
'x86-architecture.html', 'arm-architecture.html', 'cpu-benchmark.html'
317+
];
318+
319+
const isCpuPage = cpuPages.some(page => window.location.pathname.includes(page));
320+
321+
if (isCpuPage) {
322+
const subNavHTML = `
323+
<div class="sub-navbar active">
324+
<div class="sub-nav-container">
325+
<a href="${base}pages/cpu.html" class="${window.location.pathname.endsWith('cpu.html') ? 'current' : ''}">Hub</a>
326+
<a href="${base}pages/cpu-overview.html" class="${window.location.pathname.includes('overview') ? 'current' : ''}">Overview</a>
327+
<a href="${base}pages/cpu-core.html" class="${window.location.pathname.includes('core') ? 'current' : ''}">Internal Parts</a>
328+
<a href="${base}pages/cpu-fabrication.html" class="${window.location.pathname.includes('fabrication') ? 'current' : ''}">Manufacturing</a>
329+
<a href="${base}pages/x86-architecture.html" class="${window.location.pathname.includes('architecture') ? 'current' : ''}">Architecture</a>
330+
<a href="${base}pages/cpu-database.html" class="${window.location.pathname.includes('database') ? 'current' : ''}">Specs DB</a>
331+
<a href="${base}pages/intel-cpu-history.html" class="${window.location.pathname.includes('history') ? 'current' : ''}">History</a>
332+
<a href="${base}pages/cpu-benchmark.html" class="${window.location.pathname.includes('benchmark') ? 'current' : ''}">Benchmarks</a>
333+
</div>
334+
</div>`;
335+
navElement.insertAdjacentHTML('afterend', subNavHTML);
336+
}
337+
}
309338
if (footerElement) footerElement.innerHTML = footerHTML;
310339
};
311340

0 commit comments

Comments
 (0)