Skip to content

Commit aa3e7bd

Browse files
committed
Bundles path fix
1 parent f71c5c0 commit aa3e7bd

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

website/build.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ 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+
const defaultVersion = versions.find(v => v.default);
28+
return defaultVersion?.branch ?? defaultVersion?.tag;
29+
}
30+
2331
async function getAllMdFiles(dir) {
2432
const entries = await readdir(dir, { withFileTypes: true });
2533
const files = [];
@@ -285,8 +293,9 @@ async function build() {
285293
await buildBlogMenu();
286294
const mdFiles = await getAllMdFiles(config.docsDir);
287295
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>`;
296+
const bundlesPath = `${ config.bundlesPath }/${ await getDefaultVersionTarget(config.versionsFile, BRANCH) }`;
297+
const bundleScript = `<script nomodule src="${ bundlesPath }/${ config.bundleName }"></script>`;
298+
const bundleESModulesScript = `<script type="module" src="${ bundlesPath }/${ config.bundleNameESModules }"></script>`;
290299

291300
let currentVersion = '';
292301
let versionsMenu = '';

0 commit comments

Comments
 (0)