File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -162,8 +162,9 @@ export async function createMarkdownToVueRenderFn(
162
162
}
163
163
164
164
const scriptRE = / < \/ s c r i p t > /
165
+ const scriptLangTsRE = / < \s * s c r i p t [ ^ > ] * \b l a n g = [ ' " ] t s [ ' " ] [ ^ > ] * /
165
166
const scriptSetupRE = / < \s * s c r i p t [ ^ > ] * \b s e t u p \b [ ^ > ] * /
166
- const scriptClientRe = / < \s * s c r i p t [ ^ > ] * \b c l i e n t \b [ ^ > ] * /
167
+ const scriptClientRE = / < \s * s c r i p t [ ^ > ] * \b c l i e n t \b [ ^ > ] * /
167
168
const defaultExportRE = / ( (?: ^ | \n | ; ) \s * ) e x p o r t ( \s * ) d e f a u l t /
168
169
const namedDefaultExportRE = / ( (?: ^ | \n | ; ) \s * ) e x p o r t ( .+ ) a s ( \s * ) d e f a u l t /
169
170
@@ -176,10 +177,12 @@ function genPageDataCode(tags: string[], data: PageData) {
176
177
return (
177
178
scriptRE . test ( tag ) &&
178
179
! scriptSetupRE . test ( tag ) &&
179
- ! scriptClientRe . test ( tag )
180
+ ! scriptClientRE . test ( tag )
180
181
)
181
182
} )
182
183
184
+ const isUsingTS = tags . findIndex ( ( tag ) => scriptLangTsRE . test ( tag ) ) > - 1
185
+
183
186
if ( existingScriptIndex > - 1 ) {
184
187
const tagSrc = tags [ existingScriptIndex ]
185
188
// user has <script> tag inside markdown
@@ -196,7 +199,9 @@ function genPageDataCode(tags: string[], data: PageData) {
196
199
)
197
200
} else {
198
201
tags . unshift (
199
- `<script>${ code } \nexport default {name:'${ data . relativePath } '}</script>`
202
+ `<script ${ isUsingTS ? 'lang="ts"' : '' } >${ code } \nexport default {name:'${
203
+ data . relativePath
204
+ } '}</script>`
200
205
)
201
206
}
202
207
You can’t perform that action at this time.
0 commit comments