From 02be3567acbad1ea90ce412fcfb375d04c9d1df1 Mon Sep 17 00:00:00 2001 From: "Crom (Thibaut CHARLES)" Date: Sat, 27 Oct 2018 01:53:18 +0200 Subject: [PATCH] Fix: menu link active state --- js/main.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/js/main.js b/js/main.js index 33175a5..091012d 100644 --- a/js/main.js +++ b/js/main.js @@ -53,8 +53,18 @@ function setPage(path){ window.scrollTo(0, 0); $("#article-container").empty(); + + $("#left > a").each((i, elmt) => { + let hrefPath = elmt.attributes["href"].value; + if(hrefPath === "/" || path === "" || path === "/index.html") + hrefPath = "/home"; + + $(elmt).toggleClass("active", hrefPath === path); + }); + $.ajax("/pages"+path+".md") .done((res) => { + $("#article-container").html(res); const len = $("#article-container > article").length;