Fix sidebar highlighting issue

This commit is contained in:
Araozu 2024-04-23 10:44:29 -05:00
parent 5a94bc5dd3
commit c67e79f894

View File

@ -106,6 +106,7 @@ for (const entry of pagesIndex) {
import { thp_highlighter, CodeJar } from "../lexer/highlighter"; import { thp_highlighter, CodeJar } from "../lexer/highlighter";
// Add an editor to all code samples // Add an editor to all code samples
document.addEventListener("DOMContentLoaded", () => {
const code_elements = document.querySelectorAll(".language-thp"); const code_elements = document.querySelectorAll(".language-thp");
for (const e of [...code_elements]) { for (const e of [...code_elements]) {
@ -122,6 +123,7 @@ for (const entry of pagesIndex) {
tab: " ", tab: " ",
}).updateCode(code); }).updateCode(code);
} }
});
</script> </script>
<script> <script>
// Highlight the current url of the sidebar // Highlight the current url of the sidebar
@ -135,7 +137,8 @@ for (const entry of pagesIndex) {
console.log(sidebar.offsetTop); console.log(sidebar.offsetTop);
console.log(link.offsetTop); console.log(link.offsetTop);
sidebar.scrollTop = link.offsetTop - sidebar.offsetTop - 250; sidebar.scrollTop =
link.offsetTop - sidebar.offsetTop - 250;
link.classList.add("bg-pink-200", "dark:bg-pink-950"); link.classList.add("bg-pink-200", "dark:bg-pink-950");
break; break;