Skip to content

Commit c794154

Browse files
committed
feat: group download archive navigation by release status
1 parent e0f68e8 commit c794154

2 files changed

Lines changed: 36 additions & 11 deletions

File tree

apps/site/components/withReleaseSelect.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const WithReleaseSelect: FC<WithReleaseSelectProps> = ({ ...props }) => {
2424
values={navigation}
2525
as={Link}
2626
onChange={push}
27+
className="w-full md:w-64"
2728
/>
2829
);
2930
};

apps/site/util/download/archive.tsx

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,44 @@ const getCompatibleArtifacts = ({
8686

8787
/**
8888
* Generates the navigation links for the Node.js download archive
89-
* It creates a list of links for each major release, formatted with the major
90-
* version and codename if available.
89+
* It creates a list of links for each major release, grouped by status,
90+
* formatted with the major version and codename if available.
9191
*/
9292
export const getDownloadArchiveNavigation = (releases: Array<NodeRelease>) => {
93-
const items = releases.map(({ major, codename, versionWithPrefix }) => ({
94-
label: `Node.js v${major} ${codename ? `(${codename})` : ''}`,
95-
value: `/download/${versionWithPrefix}`,
96-
}));
97-
98-
return [
99-
{
100-
items,
101-
},
93+
// Define status order priority
94+
const statusOrder = [
95+
'Current',
96+
'Active LTS',
97+
'Maintenance LTS',
98+
'End-of-life',
99+
'Pending',
102100
];
101+
102+
// Group releases by status
103+
const groupedByStatus = releases.reduce(
104+
(acc, release) => {
105+
const { status, major, codename, versionWithPrefix } = release;
106+
107+
if (!acc[status]) {
108+
acc[status] = [];
109+
}
110+
111+
acc[status].push({
112+
label: `Node.js v${major} ${codename ? `(${codename})` : ''}`,
113+
value: `/download/${versionWithPrefix}`,
114+
});
115+
116+
return acc;
117+
},
118+
{} as Record<string, Array<{ label: string; value: string }>>
119+
);
120+
121+
return statusOrder
122+
.filter(status => groupedByStatus[status])
123+
.map(status => ({
124+
label: status,
125+
items: groupedByStatus[status],
126+
}));
103127
};
104128

105129
/**

0 commit comments

Comments
 (0)