Skip to content

Commit f9c71c1

Browse files
committed
fix: ts error
1 parent 5fecf9b commit f9c71c1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

packages/docs/plugins/remark-heading.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Heading,Root } from 'mdast'
1+
import type { Heading, Root } from 'mdast'
22
import type { Plugin } from 'unified'
33
import { visit } from 'unist-util-visit'
44

@@ -18,7 +18,7 @@ function generateHeadingId(text: string): string {
1818
/**
1919
* 从 MDAST 节点中提取文本内容
2020
*/
21-
21+
2222
function extractTextFromNode(node: any): string {
2323
if (typeof node === 'string') {
2424
return node
@@ -41,7 +41,9 @@ function extractTextFromNode(node: any): string {
4141
}
4242

4343
if (node.children && Array.isArray(node.children)) {
44-
return node.children.map((element) => extractTextFromNode(element)).join('')
44+
return node.children
45+
.map((element: any) => extractTextFromNode(element))
46+
.join('')
4547
}
4648

4749
return ''
@@ -97,7 +99,7 @@ const remarkHeading: Plugin<[RemarkHeadingOptions?], Root> = (options = {}) => {
9799

98100
// 提取标题文本
99101
const text = node.children
100-
.map((element) => extractTextFromNode(element))
102+
.map((element: any) => extractTextFromNode(element))
101103
.join('')
102104

103105
if (!text.trim()) {
@@ -131,4 +133,4 @@ const remarkHeading: Plugin<[RemarkHeadingOptions?], Root> = (options = {}) => {
131133
}
132134

133135
export default remarkHeading
134-
export { generateHeadingId,remarkHeading }
136+
export { generateHeadingId, remarkHeading }

0 commit comments

Comments
 (0)