mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
parent
8608a716e6
commit
2505e7f623
@ -99,14 +99,15 @@ function serializeHeader(h: Element): string {
|
||||
) {
|
||||
continue
|
||||
}
|
||||
|
||||
ret += node.textContent
|
||||
const clone = node.cloneNode(true)
|
||||
clearHeaderNodeList(Array.from(clone.childNodes))
|
||||
ret += clone.textContent
|
||||
}
|
||||
else if (node.nodeType === 3) {
|
||||
ret += node.textContent
|
||||
}
|
||||
}
|
||||
// maybe `<hx><a href="#"></a><a href="xxx"></a</hx>` or more
|
||||
// maybe `<hx><a href="#"></a><a href="xxx"></a></hx>` or more
|
||||
let next = anchor?.nextSibling
|
||||
while (next) {
|
||||
if (next.nodeType === 1 || next.nodeType === 3)
|
||||
@ -117,6 +118,21 @@ function serializeHeader(h: Element): string {
|
||||
return ret.trim()
|
||||
}
|
||||
|
||||
function clearHeaderNodeList(list?: ChildNode[]) {
|
||||
if (list?.length) {
|
||||
for (const node of list) {
|
||||
if (node.nodeType === 1) {
|
||||
if ((node as Element).classList.contains('ignore-header')) {
|
||||
node.remove()
|
||||
}
|
||||
else {
|
||||
clearHeaderNodeList(Array.from(node.childNodes))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveHeaders(headers: MenuItem[], range?: ThemeOutline): MenuItem[] {
|
||||
if (range === false)
|
||||
return []
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user