/* ========================================================================= layout.js — shared header (nav) + footer across every page Injects a single source of truth into
and
placeholders. Marks the current page link with aria-current. No fetch / no FOUC risk — pure inline strings. ========================================================================= */ (function () { 'use strict'; // pages are relative to site root; each page passes its key via const LINKS = [ { key: 'home', href: 'index.html', label: 'Home' }, { key: 'models', href: 'models.html', label: 'Models' }, { key: 'pricing', href: 'pricing.html', label: 'Pricing' }, { key: 'docs', href: 'docs.html', label: 'Docs' }, { key: 'faq', href: 'faq.html', label: 'FAQ' }, { key: 'dashboard', href: 'dashboard.html', label: 'Dashboard' }, ]; const ENDPOINT = 'https://apiarium-labs.hf.space/v1/chat/completions'; const PROVIDERS = ['Claude', 'DeepSeek', 'MiniMax', 'MiMo', 'Gemini', 'GLM', 'Qwen', 'NVIDIA', 'Kimi', 'Grok', 'Ollama', 'OpenRouter']; function navHtml(current) { const items = LINKS.map(l => `
  • ${l.label}
  • ` ).join(''); return ` `; } function footerHtml() { const provs = PROVIDERS.map(p => `${p}`).join(''); const year = new Date().getFullYear(); return ` `; } // inject + hydrate function build() { const current = document.body.dataset.page || ''; const navHost = document.querySelector('[data-site-nav]'); const footHost = document.querySelector('[data-site-footer]'); if (navHost) { navHost.innerHTML = navHtml(current); // scroll-shrink toggle const nav = navHost.querySelector('.site-nav'); if (nav) { const onScroll = () => { nav.classList.toggle('is-scrolled', window.scrollY > 40); }; window.addEventListener('scroll', onScroll, { passive: true }); onScroll(); } // swap "Sign in" → "Dashboard" if a Google session cookie exists const authLink = navHost.querySelector('#nav-auth'); if (authLink) { fetch('/auth/me').then(r => r.ok ? r.json() : null).then(me => { if (me) { // logged in authLink.textContent = 'Dashboard'; authLink.setAttribute('href', 'dashboard.html'); } }).catch(() => { /* not logged in — leave as Sign in */ }); } } if (footHost) footHost.innerHTML = footerHtml(); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', build); } else { build(); } })();