Skip to content

Commit bdd871e

Browse files
committed
chore: review updates
1 parent dd420e2 commit bdd871e

File tree

13 files changed

+61
-53
lines changed

13 files changed

+61
-53
lines changed

.github/workflows/lighthouse.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
${{ needs.get-vercel-preview.outputs.url }}/en/about
9898
${{ needs.get-vercel-preview.outputs.url }}/en/about/previous-releases
9999
${{ needs.get-vercel-preview.outputs.url }}/en/download
100-
${{ needs.get-vercel-preview.outputs.url }}/en/download/archive
100+
${{ needs.get-vercel-preview.outputs.url }}/en/download/archive/current
101101
${{ needs.get-vercel-preview.outputs.url }}/en/blog
102102
uploadArtifacts: true # save results as a action artifacts
103103
temporaryPublicStorage: true # upload lighthouse report to the temporary storage

apps/site/app/[locale]/[...path]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import { ENABLE_STATIC_EXPORT_LOCALE } from '#site/next.constants.mjs';
1515
import { dynamicRouter } from '#site/next.dynamic.mjs';
1616
import * as basePage from '#site/next.dynamic.page.mjs';
1717
import { availableLocaleCodes, defaultLocale } from '#site/next.locales.mjs';
18+
import type { DynamicParams } from '#site/types';
1819

19-
type DynamicStaticPaths = { path: Array<string>; locale: string };
20-
type DynamicParams = { params: Promise<DynamicStaticPaths> };
20+
type PageParams = DynamicParams<{ path: Array<string> }>;
2121

2222
// This is the default Viewport Metadata
2323
// @see https://nextjs.org/docs/app/api-reference/functions/generate-viewport#generateviewport-function
@@ -59,7 +59,7 @@ export const generateStaticParams = async () => {
5959
// then it proceeds to retrieve the Markdown file and parse the MDX Content into a React Component
6060
// finally it returns (if the locale and route are valid) the React Component with the relevant context
6161
// and attached context providers for rendering the current page
62-
const getPage: FC<DynamicParams> = async props => {
62+
const getPage: FC<PageParams> = async props => {
6363
const { path, locale: routeLocale } = await props.params;
6464

6565
// Gets the current full pathname for a given path

apps/site/app/[locale]/blog/[...path]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { ENABLE_STATIC_EXPORT } from '#site/next.constants.mjs';
55
import { BLOG_DYNAMIC_ROUTES } from '#site/next.dynamic.constants.mjs';
66
import * as basePage from '#site/next.dynamic.page.mjs';
77
import { defaultLocale } from '#site/next.locales.mjs';
8+
import type { DynamicParams } from '#site/types';
89

9-
type DynamicStaticPaths = { path: Array<string>; locale: string };
10-
type DynamicParams = { params: Promise<DynamicStaticPaths> };
10+
type PageParams = DynamicParams<{ path: Array<string> }>;
1111

1212
// This is the default Viewport Metadata
1313
// @see https://nextjs.org/docs/app/api-reference/functions/generate-viewport#generateviewport-function
@@ -38,7 +38,7 @@ export const generateStaticParams = async () => {
3838
// then it proceeds to retrieve the Markdown file and parse the MDX Content into a React Component
3939
// finally it returns (if the locale and route are valid) the React Component with the relevant context
4040
// and attached context providers for rendering the current page
41-
const getPage: FC<DynamicParams> = async props => {
41+
const getPage: FC<PageParams> = async props => {
4242
const { path, locale: routeLocale } = await props.params;
4343

4444
// Gets the current full pathname for a given path

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { notFound } from 'next/navigation';
1+
import { notFound, redirect } from 'next/navigation';
22
import type { FC } from 'react';
33

4+
import provideReleaseData from '#site/next-data/providers/releaseData';
45
import { ENABLE_STATIC_EXPORT } from '#site/next.constants.mjs';
56
import { ARCHIVE_DYNAMIC_ROUTES } from '#site/next.dynamic.constants.mjs';
67
import * as basePage from '#site/next.dynamic.page.mjs';
78
import { defaultLocale } from '#site/next.locales.mjs';
9+
import type { DynamicParams } from '#site/types';
810

9-
type DynamicStaticPaths = { version: string; locale: string };
10-
type DynamicParams = { params: Promise<DynamicStaticPaths> };
11+
type PageParams = DynamicParams<{ version: string }>;
1112

1213
// This is the default Viewport Metadata
1314
// @see https://nextjs.org/docs/app/api-reference/functions/generate-viewport#generateviewport-function
@@ -38,12 +39,20 @@ export const generateStaticParams = async () => {
3839
// then it proceeds to retrieve the Markdown file and parse the MDX Content into a React Component
3940
// finally it returns (if the locale and route are valid) the React Component with the relevant context
4041
// and attached context providers for rendering the current page
41-
const getPage: FC<DynamicParams> = async props => {
42+
const getPage: FC<PageParams> = async props => {
4243
const { version, locale: routeLocale } = await props.params;
4344

4445
// Gets the current full pathname for a given path
4546
const [locale, pathname] = basePage.getLocaleAndPath(version, routeLocale);
4647

48+
if (version === 'current') {
49+
const releaseData = provideReleaseData();
50+
51+
const release = releaseData.find(release => release.status === 'Current');
52+
53+
redirect(`/${locale}/download/archive/${release?.versionWithPrefix}`);
54+
}
55+
4756
// Verifies if the current route is a dynamic route
4857
const isDynamicRoute = ARCHIVE_DYNAMIC_ROUTES.some(r => r.includes(pathname));
4958

apps/site/app/[locale]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import { ENABLE_STATIC_EXPORT_LOCALE } from '#site/next.constants.mjs';
66
import * as basePage from '#site/next.dynamic.page.mjs';
77
import { availableLocaleCodes } from '#site/next.locales.mjs';
88
import { defaultLocale } from '#site/next.locales.mjs';
9+
import type { DynamicParams } from '#site/types';
910

10-
type DynamicStaticPaths = { path: Array<string>; locale: string };
11-
type DynamicParams = { params: Promise<DynamicStaticPaths> };
11+
type PageParams = DynamicParams<{ path: Array<string> }>;
1212

1313
// This is the default Viewport Metadata
1414
// @see https://nextjs.org/docs/app/api-reference/functions/generate-viewport#generateviewport-function
@@ -49,7 +49,7 @@ export const generateStaticParams = async () => {
4949
// then it proceeds to retrieve the Markdown file and parse the MDX Content into a React Component
5050
// finally it returns (if the locale and route are valid) the React Component with the relevant context
5151
// and attached context providers for rendering the current page
52-
const getPage: FC<DynamicParams> = async props => {
52+
const getPage: FC<PageParams> = async props => {
5353
const { path, locale: routeLocale } = await props.params;
5454

5555
// Gets the current full pathname for a given path

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const ReleaseCodeBox: FC = () => {
108108
>
109109
{t.rich('layouts.download.codeBox.noScriptDetected', {
110110
link: text => (
111-
<Link href="/download/archive">
111+
<Link href="/download/archive/current">
112112
<b>{text}</b>
113113
</Link>
114114
),

apps/site/components/withDownloadArchive.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { notFound } from 'next/navigation';
22
import type { FC } from 'react';
3+
import semVer from 'semver';
34

45
import { getClientContext } from '#site/client-context';
56
import provideReleaseData from '#site/next-data/providers/releaseData';
67
import {
78
buildReleaseArtifacts,
89
extractVersionFromPath,
9-
findReleaseByVersion,
1010
} from '#site/util/download/archive';
1111

1212
type DownloadArchive = ReturnType<typeof buildReleaseArtifacts>;
@@ -33,7 +33,9 @@ const WithDownloadArchive: FC<WithDownloadArchiveProps> = async ({
3333

3434
// Find the release data for the given version
3535
const releaseData = provideReleaseData();
36-
const release = findReleaseByVersion(releaseData, version);
36+
const release = releaseData.find(
37+
release => semVer.major(version) === release.major
38+
)!;
3739

3840
const releaseArtifacts = buildReleaseArtifacts(
3941
release,

apps/site/pages/en/download/current.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Learn how to <LinkWithArrow href="https://github.com/nodejs/node#verifying-binar
3030
Looking for Node.js source? Download a signed <Release.DownloadLink kind="source">Node.js source</Release.DownloadLink> tarball.
3131

3232
Check out our <LinkWithArrow href="https://nodejs.org/download/nightly/">nightly</LinkWithArrow> binaries or
33-
all <Link href="/download/archive">previous releases</Link>
33+
all <Link href="/download/archive/current">previous releases</Link>
3434
or the <LinkWithArrow href="https://unofficial-builds.nodejs.org/download/">unofficial</LinkWithArrow> binaries for other platforms.
3535

3636
</section>

apps/site/pages/en/download/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Learn how to <LinkWithArrow href="https://github.com/nodejs/node#verifying-binar
3030
Looking for Node.js source? Download a signed <Release.DownloadLink kind="source">Node.js source</Release.DownloadLink> tarball.
3131

3232
Check out our <LinkWithArrow href="https://nodejs.org/download/nightly/">nightly</LinkWithArrow> binaries or
33-
all <Link href="/download/archive">previous releases</Link>
33+
all <Link href="/download/archive/current">previous releases</Link>
3434
or the <LinkWithArrow href="https://unofficial-builds.nodejs.org/download/">unofficial</LinkWithArrow> binaries for other platforms.
3535

3636
</section>

apps/site/types/download.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ export type DownloadArtifact = {
3939
url: string;
4040
version: string;
4141
};
42+
43+
export type CompatibleArtifactOptions = {
44+
platforms?: Record<OperatingSystem, Array<DownloadDropdownItem<Platform>>>;
45+
exclude?: Array<string>;
46+
versionWithPrefix: string;
47+
kind?: DownloadKind;
48+
};
49+
50+
export type CompatiblePlatforms = Array<{
51+
os: OperatingSystem;
52+
platform: DownloadDropdownItem<Platform>;
53+
}>;

0 commit comments

Comments
 (0)