From ae7364c96ef5125cc91f49e863d9b6d178605fe8 Mon Sep 17 00:00:00 2001 From: Johnny Sung Date: Mon, 14 Sep 2026 21:14:40 +0800 Subject: [PATCH] fix: hide the table of content when it has no entries A note without headings showed an empty box, since the table of content was displayed whether or not anything ended up in it. Entries are counted rather than headings, so a heading below the configured toc depth counts as empty too. --- public/js/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/js/index.js b/public/js/index.js index 8d700f25b..ad0d504d4 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1311,7 +1311,11 @@ function generateScrollspy () { }) $(document.body).scrollspy('refresh') ui.area.view.scrollspy('refresh') - if (enoughForAffixToc) { + // without any heading the table of content is an empty box, so hide it + if ($('#ui-toc').find('.toc a').length === 0) { + ui.toc.toc.hide() + ui.toc.affix.hide() + } else if (enoughForAffixToc) { ui.toc.toc.hide() ui.toc.affix.show() } else {