From bd26c5ddab9eb8fbac3f6b21d61dc3eb62c840f2 Mon Sep 17 00:00:00 2001 From: TrebledJ <39648915+TrebledJ@users.noreply.github.com> Date: Sun, 5 Nov 2023 22:56:05 +0800 Subject: [PATCH] fix: toc scrollspy highlight --- assets/js/post.js | 2 +- assets/scss/_toc-sidebar.scss | 5 ++++- assets/scss/main.scss | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/assets/js/post.js b/assets/js/post.js index 8437ca580..02186f0d7 100644 --- a/assets/js/post.js +++ b/assets/js/post.js @@ -26,7 +26,7 @@ $(() => { // --- TOC Current Section Highlight --- // const headerOffset = 150; - const sections = document.querySelectorAll('.post-article h2,.post-article h3'); + const sections = document.querySelectorAll('.post-body h2,.post-body h3'); const mainNavLinks = document.querySelectorAll('#toc-sidebar nav.toc a'); const mobileNavLinks = document.querySelectorAll('#btn-mobile-toc nav.toc a'); diff --git a/assets/scss/_toc-sidebar.scss b/assets/scss/_toc-sidebar.scss index ada045f57..ea4855d34 100644 --- a/assets/scss/_toc-sidebar.scss +++ b/assets/scss/_toc-sidebar.scss @@ -23,11 +23,14 @@ .toc-link-container { a { color: var(--main-text-color) !important; + &:hover { + font-weight: 500; + } } a.active { color: var(--bold-color) !important; - font-weight: 600; + font-weight: 700; } } diff --git a/assets/scss/main.scss b/assets/scss/main.scss index 10b697dc1..caa19dc6e 100644 --- a/assets/scss/main.scss +++ b/assets/scss/main.scss @@ -152,7 +152,7 @@ $carousel-transition: transform 2s ease, opacity 1.5s ease-out .5s; } } - #toc-sidebar a, + #toc-sidebar a:not(.active), .dim-deep { opacity: 0.7; transition: opacity $transition-duration linear; @@ -169,7 +169,7 @@ $carousel-transition: transform 2s ease, opacity 1.5s ease-out .5s; opacity: $opacity-low; } - #toc-sidebar a, + // #toc-sidebar, .dim-deep { opacity: $opacity-lower; }