Update URL when navigating to new pages and push state to history in client-side SPA

merge-requests/30/merge
knotteye 2020-10-17 15:37:25 -05:00
parent 56c4b94a80
commit cc3876ff4a
1 changed files with 4 additions and 0 deletions

View File

@ -1,5 +1,6 @@
async function render(path){ async function render(path){
var context = await getContext(); var context = await getContext();
history.pushState({}, context.sitename, location.protocol+'//'+location.host+path);
switch(path){ switch(path){
//nothing but context //nothing but context
case (path.match(/^\/about\/?$/) || {}).input: case (path.match(/^\/about\/?$/) || {}).input:
@ -104,6 +105,9 @@ async function render(path){
case "": case "":
render('/users/live'); render('/users/live');
break; break;
case "/index.html":
render('/users/live');
break;
//404 //404
default: default:
document.body.innerHTML = nunjucks.render('404.njk', context); document.body.innerHTML = nunjucks.render('404.njk', context);