added post template
This commit is contained in:
32
post.html
Normal file
32
post.html
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Yap Sesh</title>
|
||||||
|
<link rel="stylesheet" href="styles.css">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Spectral:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;1,200;1,300;1,400;1,500;1,600;1,700;1,800&display=swap" rel="stylesheet">
|
||||||
|
<link rel="apple-touch-icon" sizes="180x180" href="./assets/apple-touch-icon.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="32x32" href="./assets/favicon-32x32.png">
|
||||||
|
<link rel="icon" type="image/png" sizes="16x16" href="./assets/favicon-16x16.png">
|
||||||
|
<link rel="manifest" href="./assets/site.webmanifest">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<a href="index.html">
|
||||||
|
<img src="assets/cabby.jpg" alt="Home" class="home-button">
|
||||||
|
</a>
|
||||||
|
</header>
|
||||||
|
<main id="content">
|
||||||
|
<article id="post"></article>
|
||||||
|
</main>
|
||||||
|
<footer>
|
||||||
|
<p>© 2025 Ryan Chou</p>
|
||||||
|
</footer>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
|
<script src="script.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
53
script.js
Normal file
53
script.js
Normal file
@@ -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 = `
|
||||||
|
<h4>${post.title}</h4>
|
||||||
|
<h3>${post.date}</h3>
|
||||||
|
<p>${post.excerpt}</p>
|
||||||
|
`;
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Reference in New Issue
Block a user