Skip to content

Commit 89a2c13

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/apps/site/npm_and_yarn-c6d5a854cf
2 parents 7f18a45 + 53d777b commit 89a2c13

148 files changed

Lines changed: 2438 additions & 811 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/site/app/[locale]/download/archive/[version]/page.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ const getPage: FC<PageParams> = async props => {
5151
if (version === 'current') {
5252
const releaseData = await provideReleaseData();
5353

54-
const release = releaseData.find(release => release.status === 'Current');
54+
// There's no Current release while the next major is in its Alpha phase
55+
const release =
56+
releaseData.find(release => release.status === 'Current') ??
57+
releaseData.find(release => release.status === 'LTS');
5558

5659
redirect(`/${locale}/download/archive/${release?.versionWithPrefix}`);
5760
}
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
'use client';
22

3-
import AvatarGroup from '@node-core/ui-components/Common/AvatarGroup';
3+
import AvatarGroupContainer from '@node-core/ui-components/Common/AvatarGroup';
44

55
import Link from '#site/components/Link';
66
import { getAuthors } from '#site/util/author';
77

88
import type { AuthorProps } from '#site/types';
99
import type { ComponentProps, FC } from 'react';
1010

11-
type WithAvatarGroupProps = Omit<
12-
ComponentProps<typeof AvatarGroup>,
11+
type AvatarGroupProps = Omit<
12+
ComponentProps<typeof AvatarGroupContainer>,
1313
'avatars' | 'as'
1414
> &
1515
AuthorProps;
1616

17-
const WithAvatarGroup: FC<WithAvatarGroupProps> = ({
17+
const AvatarGroup: FC<AvatarGroupProps> = ({
1818
usernames,
1919
names,
2020
clickable = true,
2121
...props
2222
}) => (
23-
<AvatarGroup
23+
<AvatarGroupContainer
2424
avatars={getAuthors({
2525
usernames,
2626
names,
@@ -31,4 +31,4 @@ const WithAvatarGroup: FC<WithAvatarGroupProps> = ({
3131
/>
3232
);
3333

34-
export default WithAvatarGroup;
34+
export default AvatarGroup;

‎apps/site/components/Blog/BlogPostCard/index.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import Preview from '@node-core/ui-components/Common/Preview';
22
import { useTranslations } from 'next-intl';
33

4+
import AvatarGroup from '#site/components/AvatarGroup';
45
import FormattedTime from '#site/components/Common/FormattedTime';
56
import Link from '#site/components/Link';
6-
import WithAvatarGroup from '#site/components/withAvatarGroup';
77
import { mapBlogCategoryToPreviewType } from '#site/util/blog';
88

99
import type { BlogCategory } from '#site/types';
@@ -49,7 +49,7 @@ const BlogPostCard: FC<BlogPostCardProps> = ({
4949
{description && <p className={styles.description}>{description}</p>}
5050

5151
<footer className={styles.footer}>
52-
<WithAvatarGroup names={authors} size="medium" clickable={false} />
52+
<AvatarGroup names={authors} size="medium" clickable={false} />
5353

5454
<div className={styles.author}>
5555
{authors && <p>{authors.join(', ')}</p>}

apps/site/components/withBlogCategories.tsx renamed to apps/site/components/BlogCategories.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { mapAuthorToCardAuthors } from '#site/util/author';
88
import type { BlogPostsRSC } from '#site/types';
99
import type { ComponentProps, FC } from 'react';
1010

11-
type WithBlogCategoriesProps = {
11+
type BlogCategoriesProps = {
1212
categories: ComponentProps<typeof LinkTabs>['tabs'];
1313
blogData: BlogPostsRSC & { category: string; page: number };
1414
};
@@ -18,10 +18,7 @@ const mapPaginationPages = (category: string, pages: number) =>
1818
url: `/blog/${category}/page/${page + 1}`,
1919
}));
2020

21-
const WithBlogCategories: FC<WithBlogCategoriesProps> = ({
22-
categories,
23-
blogData,
24-
}) => {
21+
const BlogCategories: FC<BlogCategoriesProps> = ({ categories, blogData }) => {
2522
const t = useTranslations();
2623

2724
return (
@@ -58,4 +55,4 @@ const WithBlogCategories: FC<WithBlogCategoriesProps> = ({
5855
);
5956
};
6057

61-
export default WithBlogCategories;
58+
export default BlogCategories;

apps/site/components/withBlogCrossLinks.tsx renamed to apps/site/components/BlogCrossLinks.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { getBlogData } from '#site/util/blog';
55
import type { BlogCategory } from '#site/types';
66
import type { FC } from 'react';
77

8-
const WithBlogCrossLinks: FC = () => {
8+
const BlogCrossLinks: FC = () => {
99
const { pathname } = getClientContext();
1010

1111
// Extracts from the static URL the components used for the Blog Post slug
@@ -48,4 +48,4 @@ const WithBlogCrossLinks: FC = () => {
4848
);
4949
};
5050

51-
export default WithBlogCrossLinks;
51+
export default BlogCrossLinks;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import Breadcrumbs from '@node-core/ui-components/Common/Breadcrumbs';
3+
import BreadcrumbsContainer from '@node-core/ui-components/Common/Breadcrumbs';
44
import { useTranslations } from 'next-intl';
55

66
import Link from '#site/components/Link';
@@ -13,11 +13,11 @@ import type { NavigationKeys } from '#site/types';
1313
import type { BreadcrumbLink } from '@node-core/ui-components/Common/Breadcrumbs';
1414
import type { FC } from 'react';
1515

16-
type WithBreadcrumbsProps = {
16+
type BreadcrumbsProps = {
1717
navKeys?: Array<NavigationKeys>;
1818
};
1919

20-
const WithBreadcrumbs: FC<WithBreadcrumbsProps> = ({ navKeys = [] }) => {
20+
const Breadcrumbs: FC<BreadcrumbsProps> = ({ navKeys = [] }) => {
2121
const { getSideNavigation } = useSiteNavigation();
2222
const t = useTranslations();
2323
const { pathname } = useClientContext();
@@ -64,7 +64,7 @@ const WithBreadcrumbs: FC<WithBreadcrumbsProps> = ({ navKeys = [] }) => {
6464
};
6565

6666
return (
67-
<Breadcrumbs
67+
<BreadcrumbsContainer
6868
links={getBreadcrumbs()}
6969
maxLength={maxLength}
7070
as={Link}
@@ -73,4 +73,4 @@ const WithBreadcrumbs: FC<WithBreadcrumbsProps> = ({ navKeys = [] }) => {
7373
);
7474
};
7575

76-
export default WithBreadcrumbs;
76+
export default Breadcrumbs;

apps/site/components/withDownloadSection.tsx renamed to apps/site/components/DownloadSection.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ import {
99
ReleasesProvider,
1010
} from '#site/providers/releaseProvider';
1111

12-
import type { NodeRelease } from '../types';
12+
import type { NodeRelease, NodeReleaseStatus } from '../types';
1313
import type { FC, PropsWithChildren } from 'react';
1414

15-
type WithDownloadSectionProps = PropsWithChildren<{
15+
type DownloadSectionProps = PropsWithChildren<{
1616
releases: Array<NodeRelease>;
1717
}>;
1818

19-
const WithDownloadSection: FC<WithDownloadSectionProps> = async ({
19+
const DownloadSection: FC<DownloadSectionProps> = async ({
2020
releases,
2121
children,
2222
}) => {
@@ -39,7 +39,11 @@ const WithDownloadSection: FC<WithDownloadSectionProps> = async ({
3939
.concat(localeSnippets);
4040

4141
// Decides which initial release to use based on the current pathname
42-
const initialRelease = pathname.endsWith('/current') ? 'Current' : 'LTS';
42+
const initialRelease: Array<NodeReleaseStatus> = pathname.endsWith('/alpha')
43+
? ['Alpha', 'Current', 'LTS']
44+
: pathname.endsWith('/current')
45+
? ['Current', 'LTS']
46+
: ['LTS'];
4347

4448
return (
4549
<WithNodeRelease status={initialRelease}>
@@ -52,4 +56,4 @@ const WithDownloadSection: FC<WithDownloadSectionProps> = async ({
5256
);
5357
};
5458

55-
export default WithDownloadSection;
59+
export default DownloadSection;

‎apps/site/components/Downloads/Release/InstallationMethodDropdown.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ const InstallationMethodDropdown: FC = () => {
2323
);
2424

2525
// We group Platforms on the Platform Dropdown to provide the User
26-
// understanding of what is recommended/official and what is not.
27-
const grouppedMethods = useMemo(
26+
// understanding of what is recommended and what is not.
27+
const groupedMethods = useMemo(
2828
() => [
2929
{
30-
label: t('layouts.download.dropdown.platformGroups.official'),
30+
label: t('layouts.download.dropdown.platformGroups.recommended'),
3131
items: parsedInstallMethods.filter(({ recommended }) => recommended),
3232
},
3333
{
34-
label: t('layouts.download.dropdown.platformGroups.unofficial'),
34+
label: t('layouts.download.dropdown.platformGroups.community'),
3535
items: parsedInstallMethods.filter(({ recommended }) => !recommended),
3636
},
3737
],
@@ -47,8 +47,8 @@ const InstallationMethodDropdown: FC = () => {
4747
if (release.os !== 'LOADING' && release.installMethod === '') {
4848
const installationMethod =
4949
// Sets either the utmost recommended platform or the first non-disabled one
50-
// Note that the first item of groupped platforms is always the recommended one
51-
nextItem<InstallationMethod | ''>('', grouppedMethods[0].items) ||
50+
// Note that the first item of grouped platforms is always the recommended one
51+
nextItem<InstallationMethod | ''>('', groupedMethods[0].items) ||
5252
nextItem<InstallationMethod | ''>('', parsedInstallMethods);
5353

5454
// This will never return an empty string as there should always be an item
@@ -75,7 +75,7 @@ const InstallationMethodDropdown: FC = () => {
7575

7676
return (
7777
<Select<InstallationMethod | ''>
78-
values={grouppedMethods}
78+
values={groupedMethods}
7979
value={release.installMethod}
8080
loading={release.os === 'LOADING' || release.installMethod === ''}
8181
ariaLabel={t('layouts.download.dropdown.platform')}

‎apps/site/components/Downloads/Release/ReleaseCodeBox.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { use, useMemo } from 'react';
99
import CodeBox from '#site/components/Common/CodeBox';
1010
import LinkWithArrow from '#site/components/Common/LinkWithArrow';
1111
import Link from '#site/components/Link';
12-
import WithReleaseAlertBox from '#site/components/withReleaseAlertBox';
12+
import ReleaseAlertBox from '#site/components/ReleaseAlertBox';
1313
import {
1414
ReleaseContext,
1515
ReleasesContext,
@@ -115,7 +115,7 @@ const usePlatformInfo = (installMethod: string) => {
115115
* ReleaseCodeBox component displays installation instructions based on platform and context
116116
*/
117117
const ReleaseCodeBox: FC = () => {
118-
const { snippets } = use(ReleasesContext);
118+
const { snippets, releases } = use(ReleasesContext);
119119
const context = use(ReleaseContext);
120120
const t = useTranslations();
121121

@@ -149,7 +149,7 @@ const ReleaseCodeBox: FC = () => {
149149
</noscript>
150150

151151
{/* Release status alert */}
152-
<WithReleaseAlertBox status={context.release.status} />
152+
<ReleaseAlertBox release={context.release} releases={releases} />
153153

154154
{/* Community platform notice */}
155155
{platformInfo.exists && !platformInfo.recommended && (

‎apps/site/components/Downloads/Release/VersionDropdown.tsx‎

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22

33
import WithNoScriptSelect from '@node-core/ui-components/Common/Select/NoScriptSelect';
44
import { useLocale, useTranslations } from 'next-intl';
5-
import { use } from 'react';
5+
import { use, useEffect } from 'react';
66

7-
import { redirect, usePathname } from '#site/navigation';
7+
import { redirect, usePathname } from '#site/navigation.mjs';
88
import { STATUS_KIND_MAP } from '#site/next.constants.mjs';
99
import {
1010
ReleaseContext,
1111
ReleasesContext,
1212
} from '#site/providers/releaseProvider';
1313

14+
import type { NodeReleaseStatus } from '#site/types';
1415
import type { FC } from 'react';
1516

1617
const VersionDropdown: FC = () => {
@@ -22,19 +23,41 @@ const VersionDropdown: FC = () => {
2223

2324
// Allows us to keep the route semantically correct to what the user should expect
2425
// from the /current and non /current routes.
26+
const getRedirectPath = (status: NodeReleaseStatus) => {
27+
if (['LTS', 'EOL'].includes(status) && !pathname.endsWith('/download')) {
28+
return '/download';
29+
}
30+
31+
if (status === 'Current' && !pathname.includes('current')) {
32+
return '/download/current';
33+
}
34+
35+
if (status === 'Alpha' && !pathname.includes('alpha')) {
36+
return '/download/alpha';
37+
}
38+
};
39+
40+
// Ensure the initial route is correct based on the release status.
41+
useEffect(() => {
42+
const redirectPath = getRedirectPath(release.status);
43+
if (redirectPath) {
44+
redirect({ href: redirectPath, locale });
45+
}
46+
// eslint-disable-next-line @eslint-react/exhaustive-deps -- deps are correct on first render, and this should not run again.
47+
}, []);
48+
49+
// Handle setting the new version or navigating to the correct route based on status.
2550
const setVersionOrNavigate = (version: string) => {
26-
const release = releases.find(
51+
const selectedRelease = releases.find(
2752
({ versionWithPrefix }) => versionWithPrefix === version
2853
);
2954

30-
if (release?.status === 'LTS' && pathname.includes('current')) {
31-
redirect({ href: '/download', locale });
32-
return;
33-
}
34-
35-
if (release?.status === 'Current' && !pathname.includes('current')) {
36-
redirect({ href: '/download/current', locale });
37-
return;
55+
if (selectedRelease) {
56+
const href = getRedirectPath(selectedRelease.status);
57+
if (href) {
58+
redirect({ href, locale });
59+
return;
60+
}
3861
}
3962

4063
setVersion(version);

0 commit comments

Comments
 (0)