diff --git a/res/index.js b/res/index.js index edfa822..3f9adbf 100644 --- a/res/index.js +++ b/res/index.js @@ -1,6 +1,7 @@ -let selectedButtonId = 'button-home'; const loadedScripts = []; +let selectedButtonId = 'button-home'; + const changeSelected = (buttonId) => { A(`#${selectedButtonId}`).removeClass('button-selected'); A(`#${buttonId}`).addClass('button-selected'); @@ -77,12 +78,15 @@ const dynamicRoutesActions = { peformRouteAction('/404'); return; } + + changeSelected(getButtonFromPathname('/blog')); blogVisitArticle(arg, desc); } }; const onButtonClick = (buttonId) => { - if (selectedButtonId === buttonId) { + // The condition after && is kinda of a hack, the reason I do this is because I want users to be able to click the blog button and return to the article list to continue reading when they are already on an article. + if (selectedButtonId === buttonId && buttonId !== 'button-blog') { return; } changeSelected(buttonId);