Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions website/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async function buildVersionsMenuList(versions, currentVersion, section) {
for (const v of versions) {
const activityClass = v.label === currentVersion && !v.default ? ' class="active"' : '';
const defaultBadge = v.default ? ' (default)' : '';
const versionPath = v.default ? '' : `${ v.label }/`;
const versionPath = v.default ? '' : `${ v.path ?? v.label }/`;
versionsMenuHtml += `<a href="./${ versionPath }${ section }"${ activityClass }>${ v.label }${ defaultBadge }</a>`;
}
versionsMenuHtml += '</div>';
Expand Down Expand Up @@ -232,8 +232,9 @@ async function buildPlaygrounds(template, versions) {
}

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

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

for (const version of versions) {
if (version.default) continue;
const menuItems = await getDocsMenuItems(version.label);
const versionPath = version.path ?? version.label;
const menuItems = await getDocsMenuItems(versionPath);
const firstDocPath = path.join(config.resultDir,
`${ menuItems[0].url }.html`.replace(`{docs-version}${ BRANCH ? '/' : '' }`, version.label));
const indexFilePath = path.join(config.resultDir, `${ version.label }/docs/`, 'index.html');
`${ menuItems[0].url }.html`.replace(`{docs-version}${ BRANCH ? '/' : '' }`, versionPath));
const indexFilePath = path.join(config.resultDir, `${ versionPath }/docs/`, 'index.html');
await copy(firstDocPath, indexFilePath);
echo(chalk.green(`File created: ${ indexFilePath }`));
}
Expand Down
6 changes: 3 additions & 3 deletions website/scripts/runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async function copyDocsToBuilder(version) {
console.time(`Copied docs to builder for "${ target }"`);
await checkoutVersion(version);
const fromDir = `${ BUILD_SRC_DIR }docs/web/docs/`;
const toDir = `${ BUILD_DOCS_DIR }${ version.label }/docs/`;
const toDir = `${ BUILD_DOCS_DIR }${ version.path ?? version.label }/docs/`;
await copyDocs(fromDir, toDir);
console.timeEnd(`Copied docs to builder for "${ target }"`);
}
Expand Down Expand Up @@ -189,7 +189,7 @@ async function checkoutVersion(version) {

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

Expand Down Expand Up @@ -333,7 +333,7 @@ try {
await buildAndCopyCoreJS(version);
}
} else {
const version = { branch: targetBranch };
const version = { branch: targetBranch, label: targetBranch };
await hasDocs(version);
await buildAndCopyCoreJS(version);
}
Expand Down