Changed it so I can just put html code in the json

This commit is contained in:
2025-10-16 17:56:29 -05:00
parent 9c9ddf6ea7
commit a27d1a9d1e
2 changed files with 16 additions and 6 deletions

View File

@ -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"));