feat: dynamically style each post
This commit is contained in:
parent
8655cd7097
commit
d3811df2ce
4 changed files with 27 additions and 18 deletions
|
|
@ -1,8 +1,17 @@
|
|||
const urlToTopic = () => {
|
||||
return new URL(window.location.href).pathname.split("/")[2];
|
||||
};
|
||||
|
||||
document.documentElement.style.setProperty(
|
||||
"--topic-color",
|
||||
getTopicColor(urlToTopic()),
|
||||
);
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll("article h2").forEach((h2) => {
|
||||
const mdHeading = document.createElement("span");
|
||||
mdHeading.textContent = "# ";
|
||||
mdHeading.style.color = "#0073e6";
|
||||
mdHeading.style.color = getTopicColor(urlToTopic());
|
||||
h2.prepend(mdHeading);
|
||||
});
|
||||
|
||||
|
|
@ -20,7 +29,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
|
||||
const mdHeading = document.createElement("span");
|
||||
mdHeading.textContent = "## ";
|
||||
mdHeading.style.color = "#0073e6";
|
||||
mdHeading.style.color = getTopicColor(urlToTopic());
|
||||
|
||||
h3.prepend(mdHeading);
|
||||
h3.prepend(toggle);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue