fix(post): proper folding and markdown header styling
This commit is contained in:
parent
7a0ffdff52
commit
872ce457f2
1 changed files with 11 additions and 20 deletions
|
|
@ -25,30 +25,21 @@ const makeFold = (h, i) => {
|
||||||
toggle.textContent = toggle.textContent === ">" ? "v" : ">";
|
toggle.textContent = toggle.textContent === ">" ? "v" : ">";
|
||||||
content.style.display = toggle.textContent === ">" ? "none" : "block";
|
content.style.display = toggle.textContent === ">" ? "none" : "block";
|
||||||
});
|
});
|
||||||
|
toggle.style.color = getTopicColor(urlToTopic());
|
||||||
|
|
||||||
const mdHeading = document.createElement("span");
|
|
||||||
console.log(
|
|
||||||
`header ${h.tagName} getting prefix ${tagToHeader.get(h.tagName)}, ${h.textContent}`,
|
|
||||||
);
|
|
||||||
const header = tagToHeader.has(h.tagName) ? tagToHeader.get(h.tagName) : "";
|
|
||||||
mdHeading.textContent = `${header} `;
|
|
||||||
mdHeading.style.color = getTopicColor(urlToTopic());
|
|
||||||
|
|
||||||
h.prepend(mdHeading);
|
|
||||||
h.prepend(toggle);
|
h.prepend(toggle);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
const setStyle = (h) => {
|
||||||
document.querySelectorAll("article h2").forEach((h2) => {
|
const mdHeading = document.createElement("span");
|
||||||
const mdHeading = document.createElement("span");
|
const header = tagToHeader.has(h.tagName) ? tagToHeader.get(h.tagName) : "";
|
||||||
mdHeading.style.fontStyle = "normal";
|
mdHeading.textContent = `${header} `;
|
||||||
mdHeading.style.color = getTopicColor(urlToTopic());
|
h.prepend(mdHeading);
|
||||||
h2.prepend(mdHeading);
|
};
|
||||||
});
|
|
||||||
|
|
||||||
document.querySelectorAll(".fold h2").forEach((x) => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
console.log("making h2 fold");
|
document.querySelectorAll(".post-article h2").forEach(setStyle);
|
||||||
makeFold(x);
|
document.querySelectorAll(".post-article h3").forEach(setStyle);
|
||||||
});
|
document.querySelectorAll(".fold h2").forEach(makeFold);
|
||||||
document.querySelectorAll(".fold h3").forEach(makeFold);
|
document.querySelectorAll(".fold h3").forEach(makeFold);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue