Skip to content

Commit f6632a2

Browse files
committed
Bundles path fix
1 parent f71c5c0 commit f6632a2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

website/build.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ let docsMenu = '';
2020
let isBlog = false;
2121
let isDocs = false;
2222

23+
async function getDefaultVersionTarget(versionFile, defaultTarget = null) {
24+
if (defaultTarget) return defaultTarget;
25+
26+
const versions = await readJson(versionFile);
27+
return versions.find(v => v.default)?.branch ?? versions.find(v => v.default)?.tag;
28+
}
29+
2330
async function getAllMdFiles(dir) {
2431
const entries = await readdir(dir, { withFileTypes: true });
2532
const files = [];
@@ -285,8 +292,9 @@ async function build() {
285292
await buildBlogMenu();
286293
const mdFiles = await getAllMdFiles(config.docsDir);
287294
const versions = await getVersions();
288-
const bundleScript = `<script nomodule src="${ config.bundlesPath }/${ DEFAULT_VERSION }/${ config.bundleName }"></script>`;
289-
const bundleESModulesScript = `<script type="module" src="${ config.bundlesPath }/${ DEFAULT_VERSION }/${ config.bundleNameESModules }"></script>`;
295+
const defaultVersionTarget = await getDefaultVersionTarget(config.versionsFile, BRANCH);
296+
const bundleScript = `<script nomodule src="${ config.bundlesPath }/${ defaultVersionTarget }/${ config.bundleName }"></script>`;
297+
const bundleESModulesScript = `<script type="module" src="${ config.bundlesPath }/${ defaultVersionTarget }/${ config.bundleNameESModules }"></script>`;
290298

291299
let currentVersion = '';
292300
let versionsMenu = '';

0 commit comments

Comments
 (0)