Skip to content

Commit 9759dd7

Browse files
committed
Versions path fix
1 parent 1711d67 commit 9759dd7

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

website/build.mjs

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

92+
function getVersionPath(version) {
93+
return version.path ?? version.branch ?? version.tag;
94+
}
95+
9296
async function buildVersionsMenuList(versions, currentVersion, section) {
9397
let versionsMenuHtml = '<div class="dropdown-block">';
9498
for (const v of versions) {
9599
const activityClass = v.label === currentVersion && !v.default ? ' class="active"' : '';
96100
const defaultBadge = v.default ? ' (default)' : '';
97-
const versionPath = v.default ? '' : `${ v.path ?? v.label }/`;
101+
const versionPath = v.default ? '' : `${ getVersionPath(v) }/`;
98102
versionsMenuHtml += `<a href="./${ versionPath }${ section }"${ activityClass }>${ v.label }${ defaultBadge }</a>`;
99103
}
100104
versionsMenuHtml += '</div>';
@@ -227,9 +231,10 @@ async function buildPlaygrounds(template, versions) {
227231
}
228232

229233
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>`;
234+
const bundlePath = version.branch ?? version.tag;
235+
const versionPath = getVersionPath(version);
236+
const bundleScript = `<script nomodule src="${ config.bundlesPath }/${ bundlePath }/${ config.bundleName }"></script>`;
237+
const bundleESModulesScript = `<script type="module" src="${ config.bundlesPath }/${ bundlePath }/${ config.bundleNameESModules }"></script>`;
233238
const babelScript = '<script src="./babel.min.js"></script>';
234239
const playgroundContent = await readFileContent(`${ config.srcDir }playground.html`);
235240
const versionsMenu = await buildVersionsMenu(versions, version.label, 'playground');
@@ -256,11 +261,11 @@ async function buildPlayground(template, version, versions) {
256261
}
257262

258263
async function createDocsIndexes(versions) {
259-
if (BRANCH) versions = [{ label: '' }];
264+
if (BRANCH) versions = [{ path: '' }];
260265

261266
for (const version of versions) {
262267
if (version.default) continue;
263-
const versionPath = version.path ?? version.label;
268+
const versionPath = getVersionPath(version);
264269
const menuItems = await getDocsMenuItems(versionPath);
265270
const firstDocPath = path.join(config.resultDir,
266271
`${ menuItems[0].url }.html`.replace(`{docs-version}${ BRANCH ? '/' : '' }`, versionPath));

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)