Refine README and add typings to ToC functions

This commit is contained in:
Emil Gulamov 2024-04-02 21:33:55 +04:00
parent e896368f49
commit 332dd8f5ce
2 changed files with 3 additions and 4 deletions

View file

@ -107,7 +107,6 @@ ScrewFast is an open-source template designed for quick and efficient web projec
### Planned Improvements ### Planned Improvements
- Currently, there are no planned improvements. We'll update this section as plans develop. - Currently, there are no planned improvements. We'll update this section as plans develop.
### Bug Fixes ### Bug Fixes
- Currently, there are no known bugs. If you encounter any issues, please report them on our [issues page](https://github.com/mearashadowfax/ScrewFast/issues). - Currently, there are no known bugs. If you encounter any issues, please report them on our [issues page](https://github.com/mearashadowfax/ScrewFast/issues).

View file

@ -160,7 +160,7 @@ const pageTitle: string = `${post.data.title} | ${SITE.title}`;
}); });
// Function to create and add an item to the ToC list // Function to create and add an item to the ToC list
function addToC(heading, tocList) { function addToC(heading: HTMLElement, tocList: HTMLElement | null) {
const li = document.createElement("li"); const li = document.createElement("li");
li.className = "toc-level-" + heading.tagName.toLowerCase(); li.className = "toc-level-" + heading.tagName.toLowerCase();
li.innerHTML =` li.innerHTML =`
@ -173,7 +173,7 @@ const pageTitle: string = `${post.data.title} | ${SITE.title}`;
return li; return li;
} }
function setActiveLink(id) { function setActiveLink(id: string) {
document.querySelectorAll("#toc li").forEach((li) => { document.querySelectorAll("#toc li").forEach((li) => {
li.classList.remove("selected"); li.classList.remove("selected");
}); });
@ -184,7 +184,7 @@ const pageTitle: string = `${post.data.title} | ${SITE.title}`;
} }
} }
function generateToC(article, tocList) { function generateToC(article: HTMLElement | null, tocList: HTMLElement | null) {
// Observe headings and add them to the ToC // Observe headings and add them to the ToC
let headings: NodeListOf<HTMLElement> | [] = article let headings: NodeListOf<HTMLElement> | [] = article
? article.querySelectorAll("h1, h2, h3, h4, h5, h6") ? article.querySelectorAll("h1, h2, h3, h4, h5, h6")