Skip to content

Commit

Permalink
chore: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Dec 5, 2024
1 parent 1832617 commit 18858f7
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/client/theme-default/composables/outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import type { Header } from '../../shared'
import { throttleAndDebounce } from '../support/utils'
import { useAside } from './aside'

const ignoreRE = /\b(?:VPBadge|header-anchor|footnote-ref|ignore-header)\b/

// cached list of anchor elements from resolveHeaders
const resolvedHeaders: { element: HTMLHeadElement; link: string }[] = []

Expand Down Expand Up @@ -45,14 +47,7 @@ function serializeHeader(h: Element): string {
let ret = ''
for (const node of h.childNodes) {
if (node.nodeType === 1) {
if (
(node as Element).classList.contains('VPBadge') ||
(node as Element).classList.contains('header-anchor') ||
(node as Element).classList.contains('footnote-ref') ||
(node as Element).classList.contains('ignore-header')
) {
continue
}
if (ignoreRE.test((node as Element).className)) continue
ret += node.textContent
} else if (node.nodeType === 3) {
ret += node.textContent
Expand Down

0 comments on commit 18858f7

Please sign in to comment.