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(); }