fix: preserve article sidebar when TOC is empty
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user