forked from autonomys/subspace-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
# Production | ||
/build | ||
|
||
/i18n | ||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { locales } = require('./docusaurus.config').i18n; | ||
|
||
const moveContents = (source, destination) => { | ||
const items = fs.readdirSync(source); | ||
|
||
items.forEach((item) => { | ||
const sourceItem = path.join(source, item); | ||
const destinationItem = path.join(destination, item); | ||
|
||
// If destination item exists, remove it | ||
if (fs.existsSync(destinationItem)) { | ||
if (fs.lstatSync(destinationItem).isDirectory()) { | ||
fs.rmdirSync(destinationItem, { recursive: true }); | ||
} else { | ||
fs.unlinkSync(destinationItem); | ||
} | ||
} | ||
|
||
// Move the source item to the destination | ||
if (fs.lstatSync(sourceItem).isDirectory()) { | ||
fs.renameSync(sourceItem, destinationItem); | ||
} else { | ||
fs.copyFileSync(sourceItem, destinationItem); | ||
} | ||
}); | ||
|
||
// Remove the now-empty source directory | ||
fs.rmdirSync(source, { recursive: true }); | ||
}; | ||
|
||
locales.forEach((locale) => { | ||
const basePath = `i18n/${locale}/docusaurus-plugin-content-docs`; | ||
|
||
moveContents(`${basePath}/current/docs`, `${basePath}/current`); | ||
moveContents(`${basePath}/versioned_docs`, basePath); | ||
}); |