@@ -167,24 +167,18 @@ function defineDefaultBlockLoader(options: DefaultBlockLoaderOptions): VueBlockL
167
167
return
168
168
}
169
169
170
- const lang
171
- = typeof block . attrs . lang === 'string'
172
- ? block . attrs . lang
173
- : options . defaultLang
170
+ const lang = typeof block . attrs . lang === 'string' ? block . attrs . lang : options . defaultLang
174
171
const extension = `.${ lang } `
175
172
176
- const files
177
- = ( await loadFile ( {
178
- getContents : ( ) => block . content ,
179
- path : `${ rawInput . path } ${ extension } ` ,
180
- srcPath : `${ rawInput . srcPath } ${ extension } ` ,
181
- extension,
182
- } ) ) || [ ]
183
-
184
- const blockOutputFile = files . find (
185
- f =>
186
- f . extension === `.${ options . defaultLang } `
187
- || options . validExtensions ?. includes ( f . extension as string ) ,
173
+ const files = await loadFile ( {
174
+ getContents : ( ) => block . content ,
175
+ path : `${ rawInput . path } ${ extension } ` ,
176
+ srcPath : `${ rawInput . srcPath } ${ extension } ` ,
177
+ extension,
178
+ } ) || [ ]
179
+
180
+ const blockOutputFile = files . find ( f =>
181
+ f . extension === `.${ options . defaultLang } ` || options . validExtensions ?. includes ( f . extension as string ) ,
188
182
)
189
183
if ( ! blockOutputFile ) {
190
184
return
@@ -193,7 +187,7 @@ function defineDefaultBlockLoader(options: DefaultBlockLoaderOptions): VueBlockL
193
187
194
188
return {
195
189
type : block . type ,
196
- attrs : toOmit ( block . attrs , 'lang' ) ,
190
+ attrs : toOmit ( block . attrs , [ 'lang' , 'generic' ] ) ,
197
191
content : blockOutputFile . contents ! ,
198
192
}
199
193
}
@@ -259,11 +253,6 @@ export const vueLoader = defineVueLoader({
259
253
function cleanupBreakLine ( str : string ) : string {
260
254
return str . replaceAll ( / ( \n \n ) \n + / g, '\n\n' ) . replace ( / ^ \s * \n | \n \s * $ / g, '' )
261
255
}
262
- function toOmit < R extends Record < keyof object , unknown > , K extends keyof R > (
263
- record : R ,
264
- toRemove : K ,
265
- ) : Omit < R , K > {
266
- return Object . fromEntries (
267
- Object . entries ( record ) . filter ( ( [ key ] ) => key !== toRemove ) ,
268
- ) as Omit < R , K >
256
+ function toOmit < R extends Record < keyof object , unknown > , K extends keyof R > ( record : R , toRemove : K [ ] ) : Omit < R , K > {
257
+ return Object . fromEntries ( Object . entries ( record ) . filter ( ( [ key ] ) => ! toRemove . includes ( key as K ) ) ) as Omit < R , K >
269
258
}
0 commit comments