@@ -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+
92100async 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
229237async 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
258267async 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
0 commit comments