Fix sidebar highlighting issue

master
Araozu 2024-04-23 10:44:29 -05:00
parent 5a94bc5dd3
commit c67e79f894
1 changed files with 17 additions and 14 deletions

View File

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