From cc3876ff4a3434267bfdaee5eb801f64b58c4548 Mon Sep 17 00:00:00 2001 From: knotteye Date: Sat, 17 Oct 2020 15:37:25 -0500 Subject: [PATCH] Update URL when navigating to new pages and push state to history in client-side SPA --- site/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site/index.js b/site/index.js index e1fadfc..ff2bc7f 100644 --- a/site/index.js +++ b/site/index.js @@ -1,5 +1,6 @@ async function render(path){ var context = await getContext(); + history.pushState({}, context.sitename, location.protocol+'//'+location.host+path); switch(path){ //nothing but context case (path.match(/^\/about\/?$/) || {}).input: @@ -104,6 +105,9 @@ async function render(path){ case "": render('/users/live'); break; + case "/index.html": + render('/users/live'); + break; //404 default: document.body.innerHTML = nunjucks.render('404.njk', context);