@@ -274,53 +274,54 @@ async function processCollectionItems(nuxt: Nuxt, collections: ResolvedCollectio
274
274
if ( ! collection . source ) {
275
275
continue
276
276
}
277
+ for await ( const source of collection . source ) {
278
+ if ( source . prepare ) {
279
+ await source . prepare ( nuxt )
280
+ }
277
281
278
- if ( collection . source . prepare ) {
279
- await collection . source . prepare ( nuxt )
280
- }
281
-
282
- const { fixed } = parseSourceBase ( collection . source )
283
- const cwd = collection . source . cwd
284
- const _keys = await fastGlob ( collection . source . include , { cwd, ignore : collection . source ! . exclude || [ ] , dot : true } )
285
- . catch ( ( ) => [ ] )
286
-
287
- filesCount += _keys . length
288
-
289
- const list : Array < Array < string > > = [ ]
290
- for await ( const chunk of chunks ( _keys , 25 ) ) {
291
- await Promise . all ( chunk . map ( async ( key ) => {
292
- key = key . substring ( fixed . length )
293
- const keyInCollection = join ( collection . name , collection . source ?. prefix || '' , key )
294
-
295
- const content = await readFile ( join ( cwd , fixed , key ) , 'utf8' )
296
- const checksum = getContentChecksum ( configHash + collectionHash + content )
297
- const cache = databaseContents [ keyInCollection ]
298
-
299
- let parsedContent
300
- if ( cache && cache . checksum === checksum ) {
301
- cachedFilesCount += 1
302
- parsedContent = JSON . parse ( cache . parsedContent )
303
- }
304
- else {
305
- parsedFilesCount += 1
306
- parsedContent = await parseContent ( keyInCollection , content , collection , nuxt )
307
- db . insertDevelopmentCache ( keyInCollection , checksum , JSON . stringify ( parsedContent ) )
308
- }
309
-
310
- list . push ( [ key , generateCollectionInsert ( collection , parsedContent ) ] )
311
- } ) )
312
- }
313
- // Sort by file name to ensure consistent order
314
- list . sort ( ( a , b ) => String ( a [ 0 ] ) . localeCompare ( String ( b [ 0 ] ) ) )
315
- collectionDump [ collection . name ] ! . push ( ...list . map ( ( [ , sql ] ) => sql ! ) )
282
+ const { fixed } = parseSourceBase ( source )
283
+ const cwd = source . cwd
284
+ const _keys = await fastGlob ( source . include , { cwd, ignore : source ! . exclude || [ ] , dot : true } )
285
+ . catch ( ( ) => [ ] )
286
+
287
+ filesCount += _keys . length
288
+
289
+ const list : Array < Array < string > > = [ ]
290
+ for await ( const chunk of chunks ( _keys , 25 ) ) {
291
+ await Promise . all ( chunk . map ( async ( key ) => {
292
+ key = key . substring ( fixed . length )
293
+ const keyInCollection = join ( collection . name , source ?. prefix || '' , key )
294
+
295
+ const content = await readFile ( join ( cwd , fixed , key ) , 'utf8' )
296
+ const checksum = getContentChecksum ( configHash + collectionHash + content )
297
+ const cache = databaseContents [ keyInCollection ]
298
+
299
+ let parsedContent
300
+ if ( cache && cache . checksum === checksum ) {
301
+ cachedFilesCount += 1
302
+ parsedContent = JSON . parse ( cache . parsedContent )
303
+ }
304
+ else {
305
+ parsedFilesCount += 1
306
+ parsedContent = await parseContent ( keyInCollection , content , collection , nuxt )
307
+ db . insertDevelopmentCache ( keyInCollection , checksum , JSON . stringify ( parsedContent ) )
308
+ }
309
+
310
+ list . push ( [ key , generateCollectionInsert ( collection , parsedContent ) ] )
311
+ } ) )
312
+ }
313
+ // Sort by file name to ensure consistent order
314
+ list . sort ( ( a , b ) => String ( a [ 0 ] ) . localeCompare ( String ( b [ 0 ] ) ) )
315
+ collectionDump [ collection . name ] ! . push ( ...list . map ( ( [ , sql ] ) => sql ! ) )
316
316
317
- collectionChecksum [ collection . name ] = hash ( collectionDump [ collection . name ] )
317
+ collectionChecksum [ collection . name ] = hash ( collectionDump [ collection . name ] )
318
318
319
- collectionDump [ collection . name ] ! . push (
320
- generateCollectionTableDefinition ( infoCollection , { drop : false } ) ,
321
- `DELETE FROM ${ infoCollection . tableName } WHERE id = 'checksum_${ collection . name } '` ,
322
- generateCollectionInsert ( infoCollection , { id : `checksum_${ collection . name } ` , version : collectionChecksum [ collection . name ] } ) ,
323
- )
319
+ collectionDump [ collection . name ] ! . push (
320
+ generateCollectionTableDefinition ( infoCollection , { drop : false } ) ,
321
+ `DELETE FROM ${ infoCollection . tableName } WHERE id = 'checksum_${ collection . name } '` ,
322
+ generateCollectionInsert ( infoCollection , { id : `checksum_${ collection . name } ` , version : collectionChecksum [ collection . name ] } ) ,
323
+ )
324
+ }
324
325
}
325
326
326
327
const sqlDumpList = Object . values ( collectionDump ) . flatMap ( a => a )
0 commit comments