Skip to content

Commit

Permalink
feat: support next release (#828)
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinderoubaix authored Jun 26, 2024
1 parent 24ace1b commit c5c7329
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
7 changes: 6 additions & 1 deletion demo/src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ export const load = async () => {
return {...ver, version: `v${ver.version}`};
}),
);
versions[1].folder = 'latest';
if (versions[1].version.match(/-next/)) {
versions[1].folder = 'next';
versions[2].folder = 'latest';
} else {
versions[1].folder = 'latest';
}
}
return {
versions,
Expand Down
8 changes: 7 additions & 1 deletion demo/src/routes/menu/Theme.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@
{/each}
</button>
{#if $open$}
<div use:directive class="dropdown-menu dropdown-menu-end bs-popover-auto position-absolute" class:show={$open$}>
<div
use:directive
class="dropdown-menu dropdown-menu-end bs-popover-auto position-absolute"
class:show={$open$}
data-popper-placement="bottom-end"
data-bs-popper="absolute"
>
{#each themes as theme, index}
<button
use:giveFocus={index}
Expand Down
27 changes: 24 additions & 3 deletions demo/src/routes/menu/Versions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,27 @@
? $page.url.pathname.replace(`/${currentVersion.folder}/`, `/${version.folder}/`)
: `${$pathToRoot$.replace(currentVersion.folder, version.folder)}docs/${$selectedFramework$}/getting-started/introduction`,
}));
const regexNext = /-next/;
$: includesNext = !!versions[1]?.version?.match?.(regexNext);
const versionLabel = (index: number, version: string, withNext: boolean) => {
if (withNext) {
if (index === 1) {
return `Next (${version})`;
} else {
return index === 2 ? `Latest (${version})` : version;
}
} else {
return index === 1 ? `Latest (${version})` : version;
}
};
</script>

<div class="nav-item">
<div class="dropdown">
<button
class="btn nav-link dropdown-toggle align-items-center d-flex {currentVersion.version === 'PREVIEW' ? 'badge text-bg-warning' : ''}"
class="btn nav-link dropdown-toggle align-items-center d-flex {currentVersion.version === 'PREVIEW' || currentVersion.folder === 'next'
? 'badge text-bg-warning'
: ''}"
aria-label="demo version select"
on:mousedown|preventDefault
on:click={() => ($open$ = !$open$)}
Expand All @@ -47,7 +62,13 @@
{currentVersion.version}
</button>
{#if $open$}
<div use:directive class="dropdown-menu dropdown-menu-end bs-popover-auto position-absolute" class:show={$open$}>
<div
use:directive
class="dropdown-menu dropdown-menu-end bs-popover-auto position-absolute"
class:show={$open$}
data-popper-placement="bottom-end"
data-bs-popper="absolute"
>
{#each versionsWithUrl as version, index}
<a
use:giveFocus={index}
Expand All @@ -58,7 +79,7 @@
$open$ = !$open$;
}}
>
{index === 1 ? `Latest (${version.version})` : version.version}
{versionLabel(index, version.version, includesNext)}
</a>
{/each}
</div>
Expand Down
12 changes: 4 additions & 8 deletions scripts/updateVersionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ const availableVersions = fs

availableVersions.sort((a, b) => -compareVersions(a.version, b.version));
fs.writeFileSync('versions.json', JSON.stringify(availableVersions));
try {
fs.unlinkSync('latest');
} catch (e) {
if (e.code !== 'ENOENT') {
throw e;
}
}
fs.symlinkSync(availableVersions[0].folder, 'latest');
fs.rmSync('next', {force: true});
fs.rmSync('latest', {force: true});
fs.symlinkSync(availableVersions[0].folder, 'next');
fs.symlinkSync(availableVersions[availableVersions[0].version.match(/-next/) ? 1 : 0].folder, 'latest');

console.log('Ordered list of available versions:');
console.log(availableVersions);

0 comments on commit c5c7329

Please sign in to comment.