Skip to content

Commit ce89bd7

Browse files
authored
Merge pull request #1467 from zloirock/docs-path
2 parents 15d7a7d + 2d20d28 commit ce89bd7

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

website/build.mjs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async function buildVersionsMenuList(versions, currentVersion, section) {
9393
for (const v of versions) {
9494
const activityClass = v.label === currentVersion && !v.default ? ' class="active"' : '';
9595
const defaultBadge = v.default ? ' (default)' : '';
96-
const versionPath = v.default ? '' : `${ v.label }/`;
96+
const versionPath = v.default ? '' : `${ v.path ?? v.label }/`;
9797
versionsMenuHtml += `<a href="./${ versionPath }${ section }"${ activityClass }>${ v.label }${ defaultBadge }</a>`;
9898
}
9999
versionsMenuHtml += '</div>';
@@ -232,8 +232,9 @@ async function buildPlaygrounds(template, versions) {
232232
}
233233

234234
async function buildPlayground(template, version, versions) {
235-
const bundleScript = `<script nomodule src="${ config.bundlesPath }/${ version.label }/${ config.bundleName }"></script>`;
236-
const bundleESModulesScript = `<script type="module" src="${ config.bundlesPath }/${ version.label }/${ config.bundleNameESModules }"></script>`;
235+
const versionPath = version.path ?? version.label;
236+
const bundleScript = `<script nomodule src="${ config.bundlesPath }/${ versionPath }/${ config.bundleName }"></script>`;
237+
const bundleESModulesScript = `<script type="module" src="${ config.bundlesPath }/${ versionPath }/${ config.bundleNameESModules }"></script>`;
237238
const babelScript = '<script src="./babel.min.js"></script>';
238239
const playgroundContent = await readFileContent(`${ config.srcDir }playground.html`);
239240
const versionsMenu = await buildVersionsMenu(versions, version.label, 'playground');
@@ -244,7 +245,7 @@ async function buildPlayground(template, version, versions) {
244245
playground = playground.replace('{core-js-bundle-esmodules}', bundleESModulesScript);
245246
playground = playground.replace('{babel-script}', babelScript);
246247
const playgroundWithVersion = playground.replace('{versions-menu}', versionsMenu);
247-
const playgroundFilePath = path.join(config.resultDir, version.label, 'playground.html');
248+
const playgroundFilePath = path.join(config.resultDir, versionPath, 'playground.html');
248249

249250
if (version.default) {
250251
const defaultVersionsMenu = await buildVersionsMenu(versions, version.label, 'playground');
@@ -264,10 +265,11 @@ async function createDocsIndexes(versions) {
264265

265266
for (const version of versions) {
266267
if (version.default) continue;
267-
const menuItems = await getDocsMenuItems(version.label);
268+
const versionPath = version.path ?? version.label;
269+
const menuItems = await getDocsMenuItems(versionPath);
268270
const firstDocPath = path.join(config.resultDir,
269-
`${ menuItems[0].url }.html`.replace(`{docs-version}${ BRANCH ? '/' : '' }`, version.label));
270-
const indexFilePath = path.join(config.resultDir, `${ version.label }/docs/`, 'index.html');
271+
`${ menuItems[0].url }.html`.replace(`{docs-version}${ BRANCH ? '/' : '' }`, versionPath));
272+
const indexFilePath = path.join(config.resultDir, `${ versionPath }/docs/`, 'index.html');
271273
await copy(firstDocPath, indexFilePath);
272274
echo(chalk.green(`File created: ${ indexFilePath }`));
273275
}

website/scripts/runner.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async function copyDocsToBuilder(version) {
136136
console.time(`Copied docs to builder for "${ target }"`);
137137
await checkoutVersion(version);
138138
const fromDir = `${ BUILD_SRC_DIR }docs/web/docs/`;
139-
const toDir = `${ BUILD_DOCS_DIR }${ version.label }/docs/`;
139+
const toDir = `${ BUILD_DOCS_DIR }${ version.path ?? version.label }/docs/`;
140140
await copyDocs(fromDir, toDir);
141141
console.timeEnd(`Copied docs to builder for "${ target }"`);
142142
}
@@ -189,7 +189,7 @@ async function checkoutVersion(version) {
189189

190190
async function buildAndCopyCoreJS(version) {
191191
const target = version.branch ?? version.tag;
192-
const name = version.label;
192+
const name = version.path ?? version.label;
193193
console.log(`Building and copying core-js for ${ target }`);
194194
const targetBundlePath = `${ BUNDLES_DIR }/${ target }/`;
195195

@@ -333,7 +333,7 @@ try {
333333
await buildAndCopyCoreJS(version);
334334
}
335335
} else {
336-
const version = { branch: targetBranch };
336+
const version = { branch: targetBranch, label: targetBranch };
337337
await hasDocs(version);
338338
await buildAndCopyCoreJS(version);
339339
}

0 commit comments

Comments
 (0)