Skip to content

Commit 53ece82

Browse files
committed
Versions path fix
1 parent 1711d67 commit 53ece82

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

website/build.mjs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,20 @@ async function buildDocsMenuForVersion(version) {
8989
return menu;
9090
}
9191

92+
function getVersionPath(version) {
93+
return version.path ?? version.branch ?? version.tag;
94+
}
95+
96+
function getBundlesPath(version) {
97+
return path.join(config.bundlesPath, version.branch ?? version.tag);
98+
}
99+
92100
async function buildVersionsMenuList(versions, currentVersion, section) {
93101
let versionsMenuHtml = '<div class="dropdown-block">';
94102
for (const v of versions) {
95103
const activityClass = v.label === currentVersion && !v.default ? ' class="active"' : '';
96104
const defaultBadge = v.default ? ' (default)' : '';
97-
const versionPath = v.default ? '' : `${ v.path ?? v.label }/`;
105+
const versionPath = v.default ? '' : `${ getVersionPath(v) }/`;
98106
versionsMenuHtml += `<a href="./${ versionPath }${ section }"${ activityClass }>${ v.label }${ defaultBadge }</a>`;
99107
}
100108
versionsMenuHtml += '</div>';
@@ -227,9 +235,10 @@ async function buildPlaygrounds(template, versions) {
227235
}
228236

229237
async function buildPlayground(template, version, versions) {
230-
const versionPath = version.branch ?? version.tag;
231-
const bundleScript = `<script nomodule src="${ config.bundlesPath }/${ versionPath }/${ config.bundleName }"></script>`;
232-
const bundleESModulesScript = `<script type="module" src="${ config.bundlesPath }/${ versionPath }/${ config.bundleNameESModules }"></script>`;
238+
const versionPath = getVersionPath(version);
239+
const bundlesPath = getBundlesPath(version);
240+
const bundleScript = `<script nomodule src="${ bundlesPath }/${ config.bundleName }"></script>`;
241+
const bundleESModulesScript = `<script type="module" src="${ bundlesPath }/${ config.bundleNameESModules }"></script>`;
233242
const babelScript = '<script src="./babel.min.js"></script>';
234243
const playgroundContent = await readFileContent(`${ config.srcDir }playground.html`);
235244
const versionsMenu = await buildVersionsMenu(versions, version.label, 'playground');
@@ -256,11 +265,11 @@ async function buildPlayground(template, version, versions) {
256265
}
257266

258267
async function createDocsIndexes(versions) {
259-
if (BRANCH) versions = [{ label: '' }];
268+
if (BRANCH) versions = [{ path: '' }];
260269

261270
for (const version of versions) {
262271
if (version.default) continue;
263-
const versionPath = version.path ?? version.label;
272+
const versionPath = getVersionPath(version);
264273
const menuItems = await getDocsMenuItems(versionPath);
265274
const firstDocPath = path.join(config.resultDir,
266275
`${ menuItems[0].url }.html`.replace(`{docs-version}${ BRANCH ? '/' : '' }`, versionPath));
@@ -294,7 +303,8 @@ async function build() {
294303
await buildBlogMenu();
295304
const mdFiles = await getAllMdFiles(config.docsDir);
296305
const versions = await getVersions();
297-
const bundlesPath = `${ config.bundlesPath }/${ await getDefaultVersionTarget(config.versionsFile, BRANCH) }`;
306+
const defaultVersion = versions.filter(v => v.default);
307+
const bundlesPath = getBundlesPath(defaultVersion);
298308
const bundleScript = `<script nomodule src="${ bundlesPath }/${ config.bundleName }"></script>`;
299309
const bundleESModulesScript = `<script type="module" src="${ bundlesPath }/${ config.bundleNameESModules }"></script>`;
300310

website/config/versions.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22
{
33
"label": "v3",
44
"default": true,
5-
"branch": "master"
5+
"branch": "master",
6+
"path": "v3"
67
},
78
{
89
"label": "v3",
9-
"branch": "master"
10+
"branch": "master",
11+
"path": "v3"
1012
},
1113
{
1214
"label": "v4 (alpha)",
13-
"path": "v4",
14-
"branch": "v4"
15+
"branch": "v4",
16+
"path": "v4"
1517
}
1618
]

0 commit comments

Comments
 (0)