From ec0b615a6c3cca2c6c34ee2535acca646bc4e0ca Mon Sep 17 00:00:00 2001 From: Erick Xavier Date: Tue, 16 Jun 2026 11:33:44 -0300 Subject: [PATCH] feat(docs): enable path-based SPA routing via 404.html Switch the Elements docs site from hash-based to path-based SPA routing to match the Core site (no-js.dev). Adds , sets useHash: false, updates syncSidebar/syncPrevNext to use location.pathname and popstate, and creates 404.html as a copy of index.html for the GitHub Pages deep-link fallback. --- docs/404.html | 873 ++++++++++++++++++++++++++++++++++++++++++++++++ docs/index.html | 17 +- 2 files changed, 882 insertions(+), 8 deletions(-) create mode 100644 docs/404.html diff --git a/docs/404.html b/docs/404.html new file mode 100644 index 0000000..53d964c --- /dev/null +++ b/docs/404.html @@ -0,0 +1,873 @@ + + + + + + + NoJS Elements — Declarative UI Components for No.JS + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + No.JS + Elements +
+ + Loading NoJS Elements… +
+ + +
+ + + + + + +
+ + +
+ Getting Started + Components + Accordion + Breadcrumb + Drag & Drop + Dropdown + Modal + Popover + Scroll Spy + Skeleton + Split Pane + Stepper + Sortable Table + Tabs + Toast + Tooltip + Tree + Validation + Virtual List + More + No.JS + NoJS LSP + NoJS Skill +
+ + +
+ + + + + +
+
+ + + +
+
+ + + + + + + + + diff --git a/docs/index.html b/docs/index.html index 010b75e..53d964c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,6 +2,7 @@ + NoJS Elements — Declarative UI Components for No.JS @@ -791,7 +792,7 @@ NoJS.config({ debug: true, router: { - useHash: true + useHash: false }, }); @@ -799,8 +800,8 @@ function syncSidebar() { var sb = document.getElementById('app-sidebar'); if (!sb) return; - var hash = location.hash.replace('#', '') || '/'; - var isHome = hash === '/' || hash === ''; + var path = location.pathname; + var isHome = path === '/' || path === ''; if (isHome) sb.classList.add('hidden'); else sb.classList.remove('hidden'); } @@ -842,27 +843,27 @@ function syncPrevNext() { var nav = document.getElementById('prev-next-nav'); if (!nav) return; - var hash = (location.hash.replace('#', '') || '/'); - var idx = pnPages.findIndex(function(p) { return p.path === hash; }); + var path = location.pathname; + var idx = pnPages.findIndex(function(p) { return p.path === path; }); if (idx === -1) { nav.style.display = 'none'; return; } nav.style.display = 'flex'; var prev = idx > 0 ? pnPages[idx - 1] : null; var next = idx < pnPages.length - 1 ? pnPages[idx + 1] : null; var html = ''; if (prev) { - html += '' + html += '' + '← Previous' + '' + prev.title + ''; } if (next) { - html += '' + html += '' + 'Next →' + '' + next.title + ''; } nav.innerHTML = html; } syncPrevNext(); - window.addEventListener('hashchange', syncPrevNext); + window.addEventListener('popstate', syncPrevNext); new MutationObserver(syncPrevNext).observe( document.querySelector('[route-view]') || document.body, { childList: true, subtree: true }