search = window.location.search.replace("?", ""); fetch("/pages/blog/"+search+".json").then(response => response.json()).then(data => { /*Grab all document elements needed*/ postTitle = document.getElementById("postTitle"); postSubTitle = document.getElementById("postSubTitle"); postDate = document.getElementById("postDate"); postText = document.getElementById("postText"); postBody = document.getElementById("postBody"); postTitle.textContent = data.title; /*Assign Post title to title header*/ postSubTitle.textContent = data.subTitle; /*Assign Sub title to sub title header*/ postDate.textContent = "Posted: " + data.date; /*Assign date to date header*/ /* Check type of post*/ if (data.postType == "text"){ postText.textContent = data.postText; } if (data.postType == "html"){ postBody.innerHTML = data.postText; } }).catch(error => console.error("Error Fetching Json"));