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
13 changes: 11 additions & 2 deletions website/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ let docsMenu = '';
let isBlog = false;
let isDocs = false;

async function getDefaultVersionTarget(versionFile, defaultTarget = null) {
if (defaultTarget) return defaultTarget;

const versions = await readJson(versionFile);
const defaultVersion = versions.find(v => v.default);
return defaultVersion?.branch ?? defaultVersion?.tag;
}

async function getAllMdFiles(dir) {
const entries = await readdir(dir, { withFileTypes: true });
const files = [];
Expand Down Expand Up @@ -285,8 +293,9 @@ async function build() {
await buildBlogMenu();
const mdFiles = await getAllMdFiles(config.docsDir);
const versions = await getVersions();
const bundleScript = `<script nomodule src="${ config.bundlesPath }/${ DEFAULT_VERSION }/${ config.bundleName }"></script>`;
const bundleESModulesScript = `<script type="module" src="${ config.bundlesPath }/${ DEFAULT_VERSION }/${ config.bundleNameESModules }"></script>`;
const bundlesPath = `${ config.bundlesPath }/${ await getDefaultVersionTarget(config.versionsFile, BRANCH) }`;
const bundleScript = `<script nomodule src="${ bundlesPath }/${ config.bundleName }"></script>`;
const bundleESModulesScript = `<script type="module" src="${ bundlesPath }/${ config.bundleNameESModules }"></script>`;

let currentVersion = '';
let versionsMenu = '';
Expand Down
2 changes: 1 addition & 1 deletion website/config/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
{
"label": "v3",
"branch": "v3"
"branch": "master"
},
{
"label": "v4 (alpha)",
Expand Down