Changed it so I can just put html code in the json
This commit is contained in:
@ -1,14 +1,24 @@
|
||||
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");
|
||||
postTitle.textContent = data.title;
|
||||
postSubTitle.textContent = data.subTitle;
|
||||
postDate.textContent = "Posted: " + data.date;
|
||||
postText.textContent = data.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"));
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user