chore(sfc-playground): improve version dropdown

This commit is contained in:
Evan You 2021-08-23 14:23:46 -04:00
parent 40994e967c
commit f173cf0026

View File

@ -47,8 +47,24 @@ async function fetchVersions(): Promise<string[]> {
const versions = releases.map(r => const versions = releases.map(r =>
/^v/.test(r.tag_name) ? r.tag_name.substr(1) : r.tag_name /^v/.test(r.tag_name) ? r.tag_name.substr(1) : r.tag_name
) )
const minVersion = versions.findIndex(v => v === '3.0.10') // if the latest version is a pre-release, list all current pre-releases
return versions.slice(0, minVersion + 1) // otherwise filter out pre-releases
let isInPreRelease = versions[0].includes('-')
const filteredVersions: string[] = []
for (const v of versions) {
if (v.includes('-')) {
if (isInPreRelease) {
filteredVersions.push(v)
}
} else {
filteredVersions.push(v)
isInPreRelease = false
}
if (filteredVersions.length >= 30 || v === '3.0.10') {
break
}
}
return filteredVersions
} }
</script> </script>