feat(posts): support links

This commit is contained in:
Barrett Ruth 2024-06-15 14:19:21 -05:00
parent f6750ade55
commit 891aea8bef

View file

@ -2,17 +2,21 @@ const postMapping = new Map([
[ [
"Software", "Software",
[ [
"from github pages to aws", { name: "from github pages to aws", link: "from-github-pages-to-aws" },
"designing this website", { name: "designing this website" },
"working in the terminal", { name: "working in the terminal" },
], ],
], ],
[ [
"Economics", "economics",
["romer-solow model", "the short run", "to invest or not to invest"], [
{ name: "romer-solow model" },
{ name: "the short run" },
{ name: "to invest or not to invest" },
],
], ],
["Trading", ["InteractiveBrokers TWS", "valuation"]], ["Trading", [{ name: "InteractiveBrokers TWS" }, { name: "valuation" }]],
["Algorithms", ["two pointers", "convex hull"]], ["Algorithms", [{ name: "two pointers" }, { name: "convex hull" }]],
]); ]);
const TERMINAL_PROMPT = "barrett@ruth:~$ "; const TERMINAL_PROMPT = "barrett@ruth:~$ ";
@ -59,13 +63,12 @@ function renderPosts(topic) {
const posts = document.getElementById("posts"); const posts = document.getElementById("posts");
posts.innerHTML = ""; posts.innerHTML = "";
postMapping.get(topic).forEach((postName) => { postMapping.get(topic).forEach(({ name: postName, link: postLink }) => {
const post = document.createElement("div"); const post = document.createElement("div");
post.classList.add("post"); post.classList.add("post");
const link = document.createElement("a"); const link = document.createElement("a");
post.classList.add("post"); link.href = postLink ? `/posts/${postLink}.html` : `/wip.html`;
link.href = `/posts/${postName.replace(/\s+/g, "-").toLowerCase()}.html`;
link.textContent = postName; link.textContent = postName;
post.appendChild(link); post.appendChild(link);