From a27d1a9d1e571939b95ad18a9d643bf6fb7ab21a Mon Sep 17 00:00:00 2001 From: TechRunner Date: Thu, 16 Oct 2025 17:56:29 -0500 Subject: [PATCH] Changed it so I can just put html code in the json --- javascript/post.js | 18 ++++++++++++++---- pages/templates/post.html | 4 ++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/javascript/post.js b/javascript/post.js index f98d0f8..fcfcd2f 100644 --- a/javascript/post.js +++ b/javascript/post.js @@ -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")); diff --git a/pages/templates/post.html b/pages/templates/post.html index 01b39db..987807d 100644 --- a/pages/templates/post.html +++ b/pages/templates/post.html @@ -14,8 +14,8 @@

Subtitle

Posted: 15 October 2025
-
-

Lorem ipsum dolor sit amet consectetur adipisicing elit. Alias a, doloremque neque culpa soluta qui itaque cupiditate necessitatibus sed delectus, nihil numquam beatae quaerat aperiam architecto commodi earum ad dolorum? Consectetur rem expedita vero voluptates dicta aperiam accusantium voluptatem vitae sunt cumque ea eum similique quod, facere iste! Aliquid, consequatur facere voluptatem corrupti laborum nihil eum? Similique enim, eos deserunt sunt deleniti adipisci dolores est accusamus quisquam incidunt voluptatem quaerat eveniet quis officia? Veritatis consectetur veniam obcaecati odit quam minus, delectus rerum sunt ipsa nostrum, enim a accusamus ducimus, placeat dolor sed architecto illum voluptatem autem animi praesentium ab est.

+
+