@@ -167,24 +167,18 @@ function defineDefaultBlockLoader(options: DefaultBlockLoaderOptions): VueBlockL
167167 return
168168 }
169169
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
174171 const extension = `.${ lang } `
175172
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 ) ,
188182 )
189183 if ( ! blockOutputFile ) {
190184 return
@@ -193,7 +187,7 @@ function defineDefaultBlockLoader(options: DefaultBlockLoaderOptions): VueBlockL
193187
194188 return {
195189 type : block . type ,
196- attrs : toOmit ( block . attrs , 'lang' ) ,
190+ attrs : toOmit ( block . attrs , [ 'lang' , 'generic' ] ) ,
197191 content : blockOutputFile . contents ! ,
198192 }
199193 }
@@ -259,11 +253,6 @@ export const vueLoader = defineVueLoader({
259253function cleanupBreakLine ( str : string ) : string {
260254 return str . replaceAll ( / ( \n \n ) \n + / g, '\n\n' ) . replace ( / ^ \s * \n | \n \s * $ / g, '' )
261255}
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 >
269258}
0 commit comments