From df7ca8a739e4f8a7b8d86bfe0baae0a92711100a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Aug 2026 13:49:56 +0800 Subject: [PATCH] fix: preserve article sidebar when TOC is empty --- assets/js/page-template.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/js/page-template.js b/assets/js/page-template.js index 25713d3d..4ac0daca 100644 --- a/assets/js/page-template.js +++ b/assets/js/page-template.js @@ -111,10 +111,11 @@ if (!hasToc) { tocWidgets.forEach(function (box) { - var host = box.closest('.widget') || box.parentElement; - // Prefer removing the whole widget chrome when empty. - if (host && host !== document.body && host.querySelectorAll('.posts-nav-box').length <= 1) { - host.remove(); + var widget = box.closest('.widget'); + // A built-in TOC is a direct child of the article sidebar. Its parent + // is therefore not widget chrome and must never be removed here. + if (widget && widget !== document.body && widget.querySelectorAll('.posts-nav-box').length <= 1) { + widget.remove(); } else { box.remove(); }