Skip to content

Commit 02b3078

Browse files
authored
Hide pre-releases older than 9 months on downloads page (betaflight#5072)
Hide pre-releases older than 9 months on the downloads page Stable releases keep the 4-year window. Pre-releases (RCs, alphas, betas) only render when they were published in the last 9 months, so the recent-releases list stays focused on the current cycle.
1 parent a863ab0 commit 02b3078

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

scripts/generate-downloads-index.mjs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ function renderLatestStableSection(latest) {
182182
}
183183

184184
const RECENT_RELEASE_YEARS = 4;
185+
const PRERELEASE_VISIBILITY_MONTHS = 9;
185186
const RELEASES_INDEX_URL = "https://github.com/betaflight/betaflight-configurator/releases";
186187

187188
function renderReleaseHistorySection(releases) {
@@ -195,7 +196,21 @@ function renderReleaseHistorySection(releases) {
195196

196197
const cutoff = new Date();
197198
cutoff.setFullYear(cutoff.getFullYear() - RECENT_RELEASE_YEARS);
198-
const recent = releases.filter((r) => r.published_at && new Date(r.published_at) >= cutoff);
199+
const prereleaseCutoff = new Date();
200+
prereleaseCutoff.setMonth(prereleaseCutoff.getMonth() - PRERELEASE_VISIBILITY_MONTHS);
201+
const recent = releases.filter((r) => {
202+
if (!r.published_at) {
203+
return false;
204+
}
205+
const published = new Date(r.published_at);
206+
if (published < cutoff) {
207+
return false;
208+
}
209+
if (r.prerelease && published < prereleaseCutoff) {
210+
return false;
211+
}
212+
return true;
213+
});
199214
const olderCount = releases.length - recent.length;
200215
const olderNote = olderCount
201216
? `<p class="meta">Earlier releases are available on <a href="${RELEASES_INDEX_URL}">GitHub</a>.</p>`

0 commit comments

Comments
 (0)