Skip to content

Commit af2d75f

Browse files
committed
Optimized JS to hide empty ToC.
1 parent cd5df3d commit af2d75f

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

assets/js/_src/toc.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
*/
77

88
$(function() {
9-
// Hide ToC title if there is no head
10-
if ($("#toc-wrap>nav#toc>ul>li").length == 0) {
11-
$("#toc-wrap>h3").addClass("hidden");
9+
if ($("#post-wrap .post-content h1").length == 0
10+
&& $("#post-wrap .post-content h2").length == 0
11+
&& $("#post-wrap .post-content h3").length == 0
12+
&& $("#post-wrap .post-content h4").length == 0
13+
&& $("#post-wrap .post-content h5").length == 0) {
14+
$("#toc-wrap").addClass("hidden");
1215
}
1316
});

assets/js/dist/toc.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)