forked from autonomys/subspace-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy-all-versions.js
32 lines (25 loc) · 961 Bytes
/
copy-all-versions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const fs = require('fs-extra');
const path = require('path');
// Import the docusaurus config
const docusaurusConfig = require('./docusaurus.config.js');
// Get the locales from the config
const locales = docusaurusConfig.i18n.locales;
async function copyDocsForLocalization() {
for (const locale of locales) {
const destination = path.join('i18n', locale, 'docusaurus-plugin-content-docs');
// Copy the current docs
await fs.copy('docs', path.join(destination, 'current'));
// Get all directories in the versioned_docs folder
const versionDirs = fs.readdirSync('versioned_docs').filter((file) =>
fs.statSync(path.join('versioned_docs', file)).isDirectory()
);
// Copy each version directory
for (const versionDir of versionDirs) {
await fs.copy(
path.join('versioned_docs', versionDir),
path.join(destination, versionDir)
);
}
}
}
copyDocsForLocalization().catch(console.error);