Skip to content

Commit 18858f7

Browse files
committed
chore: simplify code
1 parent 1832617 commit 18858f7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/client/theme-default/composables/outline.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import type { Header } from '../../shared'
55
import { throttleAndDebounce } from '../support/utils'
66
import { useAside } from './aside'
77

8+
const ignoreRE = /\b(?:VPBadge|header-anchor|footnote-ref|ignore-header)\b/
9+
810
// cached list of anchor elements from resolveHeaders
911
const resolvedHeaders: { element: HTMLHeadElement; link: string }[] = []
1012

@@ -45,14 +47,7 @@ function serializeHeader(h: Element): string {
4547
let ret = ''
4648
for (const node of h.childNodes) {
4749
if (node.nodeType === 1) {
48-
if (
49-
(node as Element).classList.contains('VPBadge') ||
50-
(node as Element).classList.contains('header-anchor') ||
51-
(node as Element).classList.contains('footnote-ref') ||
52-
(node as Element).classList.contains('ignore-header')
53-
) {
54-
continue
55-
}
50+
if (ignoreRE.test((node as Element).className)) continue
5651
ret += node.textContent
5752
} else if (node.nodeType === 3) {
5853
ret += node.textContent

0 commit comments

Comments
 (0)