fix(sidebar): remove ignored headings and children (#2580)

This commit is contained in:
Luffy 2025-08-25 10:34:58 +08:00 committed by GitHub
parent 22ac7e855d
commit 2a49bd0aa4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -200,13 +200,10 @@ export class Compiler {
if (toc[i].ignoreSubHeading) {
const deletedHeaderLevel = toc[i].depth;
toc.splice(i, 1);
// Remove headers who are under current header
for (
let j = i;
j < toc.length && deletedHeaderLevel < toc[j].depth;
j++
) {
toc.splice(j, 1) && j-- && i++;
// Remove all following headings with greater depth
while (i < toc.length && toc[i].depth > deletedHeaderLevel) {
toc.splice(i, 1);
}
i--;