const content = document.getElementById('page-content'); const loader = document.getElementById('loader'); // Whitelist of pages: name -> file (and title) const routes = { home: { url: 'pages/home.html', title: 'Home' }, about: { url: 'pages/about.html', title: 'About' }, community: { url: 'pages/community.html', title: 'Community' }, blog: { url: 'pages/blog.html', title: 'Blog' }, join: { url: 'pages/join.html', title: 'Join' }, privacy: { url: 'pages/privacy-policy.html', title: 'Privacy Policy' }, }; let controller; async function loadPage() { const name = location.hash.slice(1) || 'home'; document.querySelectorAll('nav a').forEach(a => { if (a.getAttribute('href') === `#${name}`) a.setAttribute('aria-current', 'page'); else a.removeAttribute('aria-current'); }); const route = routes[name]; if (!route) { content.innerHTML = '
Sorry, that page failed to load.
'; console.error(err); } finally { loader.hidden = true; } } window.addEventListener('hashchange', loadPage); loadPage();