From 5f12d1aaaa8c5e301c125fe47a03bf3b9a421fb3 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Mon, 10 Nov 2025 01:07:00 -0500 Subject: [PATCH] fix(ui): color git properly --- public/scripts/index.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/public/scripts/index.js b/public/scripts/index.js index ed90fb9..bfbc429 100644 --- a/public/scripts/index.js +++ b/public/scripts/index.js @@ -136,13 +136,27 @@ const delay = 500; const colorFn = window.getTopicColor || (() => ""); - document.querySelectorAll("[data-topic]").forEach((t) => { - t.classList.remove("active"); - t.style.color = ""; - }); - link.classList.add("active"); - const c = colorFn(topic); - if (c) link.style.color = c; + const topicKey = topic.split("/")[0]; + const willNavigateAway = !( + isHome && + topic && + window.postsByCategory && + window.postsByCategory[topic] + ); + + if (willNavigateAway) { + link.classList.add("active"); + const c = colorFn(topicKey); + if (c) link.style.color = c; + } else { + document.querySelectorAll("[data-topic]").forEach((t) => { + t.classList.remove("active"); + t.style.color = ""; + }); + link.classList.add("active"); + const c = colorFn(topicKey); + if (c) link.style.color = c; + } const displayPath = isHome ? `/${topic}` : displayPathFromHref(href);