@@ -245,6 +245,9 @@ async function migrateContent(targetRepos, ghCloneDir, outputDirs, options) {
245245 )
246246 for ( let i = targetReleaseRefs . length - 1 ; i >= 0 ; i -- ) {
247247 const targetRef = targetReleaseRefs [ i ]
248+ const versionString = repoConfig . versionedDocs
249+ ? targetRef . versionString
250+ : ''
248251
249252 try {
250253 migrateRepoContentAtRef (
@@ -260,13 +263,13 @@ async function migrateContent(targetRepos, ghCloneDir, outputDirs, options) {
260263
261264 successes . push ( {
262265 repoSlug,
263- versionString : targetRef . versionString ,
266+ versionString,
264267 } )
265268 } catch ( error ) {
266269 console . error ( `🔴 Failed to extract content from "${ repoSlug } "` , error )
267270 failures . push ( {
268271 repoSlug,
269- versionString : targetRef . versionString ,
272+ versionString,
270273 hash : targetRef . hash ,
271274 error : error . stack ,
272275 } )
@@ -336,27 +339,18 @@ function migrateRepoContentAtRef(
336339 * TODO: investigate why `terraform-cdk` doesn't seem to have an asset
337340 * directory. Maybe intentional, in which case this conditional is fine.
338341 */
342+ const version = repoConfig . versionedDocs ? targetRef . versionString : ''
339343 if ( typeof repoConfig . assetDir === 'string' ) {
340344 const assetsSrc = path . join ( websiteDirPath , repoConfig . assetDir )
341- const assetsDest = path . join (
342- outputDirs . content ,
343- repoSlug ,
344- targetRef . versionString ,
345- 'img' ,
346- )
345+ const assetsDest = path . join ( outputDirs . content , repoSlug , version , 'img' )
347346
348347 if ( fs . existsSync ( assetsSrc ) ) {
349348 dirsToCopy . push ( { src : assetsSrc , dest : assetsDest } )
350349 }
351350 } else if ( Array . isArray ( repoConfig . assetDir ) ) {
352351 for ( const assetDir of repoConfig . assetDir ) {
353352 const assetsSrc = path . join ( websiteDirPath , assetDir )
354- const assetsDest = path . join (
355- outputDirs . content ,
356- repoSlug ,
357- targetRef . versionString ,
358- 'img' ,
359- )
353+ const assetsDest = path . join ( outputDirs . content , repoSlug , version , 'img' )
360354
361355 if ( fs . existsSync ( assetsSrc ) ) {
362356 dirsToCopy . push ( { src : assetsSrc , dest : assetsDest } )
@@ -369,14 +363,14 @@ function migrateRepoContentAtRef(
369363 const contentDest = path . join (
370364 outputDirs . content ,
371365 repoSlug ,
372- targetRef . versionString ,
366+ version ,
373367 repoConfig . contentDir ,
374368 )
375369 const dataSrc = path . join ( websiteDirPath , repoConfig . dataDir )
376370 const dataDest = path . join (
377371 outputDirs . content ,
378372 repoSlug ,
379- targetRef . versionString ,
373+ version ,
380374 repoConfig . dataDir ,
381375 )
382376
@@ -388,7 +382,7 @@ function migrateRepoContentAtRef(
388382 const redirectsDest = path . join (
389383 outputDirs . content ,
390384 repoSlug ,
391- targetRef . versionString ,
385+ version ,
392386 'redirects.jsonc' ,
393387 )
394388 dirsToCopy . push ( { src : redirectsSrcJsonc , dest : redirectsDest } )
0 commit comments