feat(posts): support links
This commit is contained in:
parent
f6750ade55
commit
891aea8bef
1 changed files with 13 additions and 10 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue