diff --git a/scripts/assets/helpers.js b/scripts/assets/helpers.js index 5b493ea..b0d1b46 100644 --- a/scripts/assets/helpers.js +++ b/scripts/assets/helpers.js @@ -12,6 +12,15 @@ const getSelectedCombination = () => { const getSelectBoxes = () => document.querySelectorAll(".selectbox"); const getPosts = () => document.querySelectorAll(".post"); +const getTutorialLinks = () => document.querySelectorAll("[data=tutorial-link]") + +const setSelectedTutorialLink = () => { + getTutorialLinks().forEach((tutorialLink) => { + if(tutorialLink.href === window.location.href) { + tutorialLink.classList.add("selected"); + } + }); +}; const onOutsideClick = (container) => { document.addEventListener("click", (event) => { @@ -129,6 +138,7 @@ const updateCombination = () => { }; window.onload = () => { + setSelectedTutorialLink(); updateCombination(); getSelectBoxes().forEach((selectbox) => { const selected = selectbox.querySelector(".selectbox-selected"); diff --git a/scripts/index-template.ejs b/scripts/index-template.ejs index 5d59bce..bd34ab4 100644 --- a/scripts/index-template.ejs +++ b/scripts/index-template.ejs @@ -50,12 +50,12 @@ <% } %>