diff --git a/post.html b/post.html new file mode 100644 index 0000000..27eaa04 --- /dev/null +++ b/post.html @@ -0,0 +1,32 @@ + + + + + + Yap Sesh + + + + + + + + + + +
+ + Home + +
+
+
+
+ + + + + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..8a78bcf --- /dev/null +++ b/script.js @@ -0,0 +1,53 @@ +document.addEventListener("DOMContentLoaded", function () { + let lastScrollY = window.scrollY; + const header = document.querySelector("header"); + + window.addEventListener("scroll", () => { + if (window.scrollY > lastScrollY) { + // Scrolling down + header.classList.add("hide-header"); + } else { + // Scrolling up + header.classList.remove("hide-header"); + } + lastScrollY = window.scrollY; + }); + + // Dynamically load posts on the home page + if (document.getElementById("post-list")) { + const posts = [ + { title: "Hemming", date: "Jul 28, 2025", excerpt: "Everything I create lives on screens", file: "post3.md" }, + { title: "Scars, Sadness, and Soulmates", date: "Jan 26, 2025", excerpt: "Healing isn't a prerequisite for love, being human is.", file: "post2.md" }, + { title: "Meaningful Action", date: "Jan 23, 2025", excerpt: "wow this is barely comprehensible", file: "post1.md" }, + ]; + + const postList = document.getElementById("post-list"); + posts.forEach(post => { + const postElement = document.createElement("div"); + postElement.classList.add("post-card"); + postElement.innerHTML = ` +

${post.title}

+

${post.date}

+

${post.excerpt}

+ `; + + postElement.addEventListener("click", () => { + window.location.href = `post.html?file=posts/${post.file}`; + }); + + postList.appendChild(postElement); + }); + } + + // Load specific post content on the post page + const urlParams = new URLSearchParams(window.location.search); + const postFile = urlParams.get("file"); + if (postFile) { + fetch(postFile) + .then(response => response.text()) + .then(text => { + document.getElementById("post").innerHTML = marked.parse(text); + }); + } +}); +