feat(posts): remove folds

This commit is contained in:
Barrett Ruth 2024-11-29 19:38:44 -06:00
parent 0e6cc1de7a
commit ed0c3b7ab2
8 changed files with 49 additions and 111 deletions

View file

@ -1,9 +0,0 @@
#!/bin/sh
[ "$#" -lt 1 ] && echo "Usage: $0 <distribution-id> <path1> [path2 ...]" && exit 1
DISTRIBUTION_ID="$1"
shift
aws cloudfront create-invalidation --distribution-id "$DISTRIBUTION_ID" --paths "$*"

View file

@ -8,28 +8,6 @@ const tagToHeader = new Map([
["H3", "##"],
]);
const makeFold = (h, i) => {
const toggle = document.createElement("span");
toggle.style.fontStyle = "normal";
toggle.textContent = ">";
// only unfold first algorithm problem
if (urlToTopic() === "algorithms" && i === 0) toggle.textContent = "v";
h.parentElement.nextElementSibling.style.display =
toggle.textContent === ">" ? "none" : "block";
h.parentE;
toggle.classList.add("fold-toggle");
toggle.addEventListener("click", () => {
const content = h.parentElement.nextElementSibling;
toggle.textContent = toggle.textContent === ">" ? "v" : ">";
content.style.display = toggle.textContent === ">" ? "none" : "block";
});
toggle.style.color = getTopicColor(urlToTopic());
h.prepend(toggle);
};
const setStyle = (h) => {
const mdHeading = document.createElement("span");
const header = tagToHeader.has(h.tagName) ? tagToHeader.get(h.tagName) : "";
@ -41,6 +19,4 @@ const setStyle = (h) => {
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll(".post-article h2").forEach(setStyle);
document.querySelectorAll(".post-article h3").forEach(setStyle);
document.querySelectorAll(".fold h2").forEach(makeFold);
document.querySelectorAll(".fold h3").forEach(makeFold);
});