@@ -88,8 +88,13 @@ async function buildDocsMenuForVersion(version) {
8888}
8989
9090async function buildPlaygroundMenuForVersion ( versions , currentVersion ) {
91+ let defaultVersionTag = `<a href="./playground">${ DEFAULT_VERSION } (default)</a>` ;
92+ if ( currentVersion === '' ) {
93+ currentVersion = `${ DEFAULT_VERSION } (default)` ;
94+ defaultVersionTag = `<a href="./playground" class="active">${ DEFAULT_VERSION } (default)</a>` ;
95+ }
9196 let versionsMenuHtml = `<div class="dropdown versions-menu"><div class="dropdown-wrapper"><a href="#" class="current">${
92- currentVersion } </a><div class="dropdown-block"><a href="./playground"> ${ DEFAULT_VERSION } (default)</a> `;
97+ currentVersion } </a><div class="dropdown-block">${ defaultVersionTag } `;
9398 if ( versions . length >= 1 ) {
9499 for ( const v of versions ) {
95100 const activityClass = v === currentVersion ? ' class="active"' : '' ;
@@ -268,13 +273,15 @@ async function buildPlayground(template, version, versions) {
268273 playground = playground . replace ( '{base}' , `${ BASE } ` ) ;
269274 playground = playground . replace ( '{core-js-bundle}' , `${ bundleScript } ` ) ;
270275 playground = playground . replace ( '{core-js-bundle-esmodules}' , `${ bundleESModulesScript } ` ) ;
271- playground = playground . replace ( '{versions-menu}' , `${ versionsMenu } ` ) ;
276+ const playgroundWithVersion = playground . replace ( '{versions-menu}' , `${ versionsMenu } ` ) ;
272277 const playgroundFilePath = path . join ( RESULT_DIR , version , 'playground.html' ) ;
273278 await fs . mkdir ( path . dirname ( playgroundFilePath ) , { recursive : true } ) ;
274- await fs . writeFile ( playgroundFilePath , playground , 'utf8' ) ;
279+ await fs . writeFile ( playgroundFilePath , playgroundWithVersion , 'utf8' ) ;
275280 if ( version === DEFAULT_VERSION ) {
281+ const defaultVersionsMenu = await buildPlaygroundMenuForVersion ( versions , '' ) ;
282+ const defaultVersionPlayground = playground . replace ( '{versions-menu}' , `${ defaultVersionsMenu } ` ) ;
276283 const defaultPlaygroundPath = path . join ( RESULT_DIR , 'playground.html' ) ;
277- await fs . writeFile ( defaultPlaygroundPath , playground , 'utf8' ) ;
284+ await fs . writeFile ( defaultPlaygroundPath , defaultVersionPlayground , 'utf8' ) ;
278285 echo ( chalk . green ( `File created: ${ defaultPlaygroundPath } ` ) ) ;
279286 }
280287
0 commit comments