@@ -324,26 +324,35 @@ export function groupEntries(collection: Collection, extension: string, entries:
324324
325325 const groupedEntries = Object . values ( grouped ) . reduce ( ( acc , values ) => {
326326 const entryValue = mergeValues ( collection , structure , defaultLocale , values ) ;
327+ if ( values [ 0 ] ?. value ?. slug !== entryValue . slug ) {
328+ entryValue . srcSlug = values [ 0 ] ?. value ?. slug ;
329+ }
327330 return [ ...acc , entryValue ] ;
328331 } , [ ] as EntryValue [ ] ) ;
329332
330333 return groupedEntries ;
331334}
332335
336+ function compareFilePathEndings ( path1 : string , path2 : string , subfolders = false ) {
337+ const [ p1 , p2 ] = [ path1 , path2 ] . map ( p => p . split ( '/' ) ) ;
338+ return subfolders ? p1 . slice ( - 2 ) . join ( '/' ) === p2 . slice ( - 2 ) . join ( '/' ) : p1 . at ( - 1 ) === p2 . at ( - 1 ) ;
339+ }
340+
333341export function getI18nDataFiles (
334342 collection : Collection ,
335343 extension : string ,
336344 path : string ,
337345 slug : string ,
338- diffFiles : { path : string ; id : string ; newFile : boolean } [ ] ,
346+ diffFiles : { path : string ; id : string ; newFile : boolean ; prevPath ?: string } [ ] ,
339347) {
340348 const { structure } = getI18nInfo ( collection ) as I18nInfo ;
341349 if ( structure === I18N_STRUCTURE . SINGLE_FILE ) {
342350 return diffFiles ;
343351 }
344352 const paths = getFilePaths ( collection , extension , path , slug ) ;
353+ const subfolders = collection . get ( 'nested' ) ?. get ( 'subfolders' ) !== false ;
345354 const dataFiles = paths . reduce ( ( acc , path ) => {
346- const dataFile = diffFiles . find ( file => file . path === path ) ;
355+ const dataFile = diffFiles . find ( file => compareFilePathEndings ( file . path , path , subfolders ) ) ;
347356 if ( dataFile ) {
348357 return [ ...acc , dataFile ] ;
349358 } else {
0 commit comments