my-portfolio/dist/blog/index.js
rodude123 23f7ff4dc5 added some base code for the blog page nothing fancy
Signed-off-by: rodude123 <rodude123@gmail.com>
2023-06-03 14:09:23 +01:00

1 line
365 B
JavaScript

function goToURL(o){let t=o.split("/"),e="";t.includes("blog")&&(e=o),"post"===t[0]&&(e="/blog/"+o),window.history.pushState(null,null,e),document.querySelector("#url").innerHTML=decodeURI(t[t.length-1])}document.addEventListener("DOMContentLoaded",(()=>{goToURL(window.location.pathname)})),window.addEventListener("popstate",(o=>{goToURL(window.history.state)}));