Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Commit ddfbcf1

Browse files
committed
fix(docz-core): async plugin
1 parent 4ac6d7e commit ddfbcf1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/docz-core/src/utils/plugin-hast.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import visit from 'unist-util-visit'
1+
import is from 'unist-util-is'
22
import nodeToString from 'hast-util-to-string'
33

44
import { format } from '../utils/format'
@@ -41,11 +41,15 @@ const addComponentsProp = (node: any) => {
4141
}
4242
}
4343

44-
export const plugin = () => async (tree: any, file: any) => {
45-
visit(tree, 'jsx', visitor)
46-
47-
async function visitor(node: any, idx: any, parent: any): Promise<void> {
44+
export const plugin = () => (tree: any, file: any) => {
45+
async function visitor(node: any): Promise<void> {
4846
await addCodeProp(node)
4947
addComponentsProp(node)
5048
}
49+
50+
const nodes = [
51+
tree.children.filter((node: any) => is('jsx', node)).map(visitor),
52+
]
53+
54+
return Promise.all(nodes).then(() => tree)
5155
}

0 commit comments

Comments
 (0)