fix: add location only when toc item is at the same level as the section (#1220)

This commit is contained in:
Huang Xin
2025-05-22 14:08:52 +08:00
committed by GitHub
parent 9674b45cf0
commit 401f28847c
+5 -1
View File
@@ -75,7 +75,11 @@ const updateTocData = (
const section = sections[id];
if (section) {
item.cfi = section.cfi;
item.location = section.location;
// Add location only when toc item is at the same level as the section
// otherwise the location will not be accurate
if (id === item.href) {
item.location = section.location;
}
}
}
if (item.subitems) {