Skip to content

Commit 5372a83

Browse files
committed
fix: setup client arg
1 parent 0eab9aa commit 5372a83

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

packages/slidev/node/plugins/setupClient.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,30 @@ export function createClientSetupPlugin({ clientRoot, themeRoots, userRoot }: Re
2828
return
2929

3030
imports.push(`import __n${idx} from '${toAtFS(path)}'`)
31+
32+
let fn = `__n${idx}`
33+
let awaitFn = `await __n${idx}`
34+
35+
if (/\binjection_return\b/g.test(code)) {
36+
fn = `injection_return = ${fn}`
37+
awaitFn = `injection_return = ${awaitFn}`
38+
}
39+
if (/\binjection_arg\b/g.test(code)) {
40+
fn += ('(injection_arg)')
41+
awaitFn += ('(injection_arg)')
42+
}
43+
else {
44+
fn += ('()')
45+
awaitFn += ('()')
46+
}
47+
3148
injections.push(
3249
`// ${path}`,
33-
(code.includes('injection_return'))
34-
? `injection_return = __n${idx}();`
35-
: `__n${idx}();`,
50+
fn,
3651
)
3752
asyncInjections.push(
3853
`// ${path}`,
39-
`await __n${idx}(injection_arg);`,
54+
awaitFn,
4055
)
4156
})
4257

0 commit comments

Comments
 (0)