Skip to content

Commit 7efa770

Browse files
authored
chore: better links for source (#7428)
* chore: better links for source * chore: addressed feedback
1 parent 6fed09a commit 7efa770

File tree

7 files changed

+59
-22
lines changed

7 files changed

+59
-22
lines changed

apps/site/components/Downloads/DownloadLink.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,32 @@
22

33
import type { FC, PropsWithChildren } from 'react';
44

5+
import LinkWithArrow from '@/components/LinkWithArrow';
56
import { useClientContext } from '@/hooks';
67
import type { NodeRelease } from '@/types';
8+
import type { DownloadKind } from '@/util/getNodeDownloadUrl';
79
import { getNodeDownloadUrl } from '@/util/getNodeDownloadUrl';
810
import { getUserPlatform } from '@/util/getUserPlatform';
911

10-
type DownloadLinkProps = { release: NodeRelease };
12+
type DownloadLinkProps = { release: NodeRelease; kind?: DownloadKind };
1113

1214
const DownloadLink: FC<PropsWithChildren<DownloadLinkProps>> = ({
1315
release: { versionWithPrefix },
16+
kind = 'installer',
1417
children,
1518
}) => {
1619
const { os, bitness, architecture } = useClientContext();
1720

1821
const platform = getUserPlatform(architecture, bitness);
19-
const downloadLink = getNodeDownloadUrl(versionWithPrefix, os, platform);
2022

21-
return <a href={downloadLink}>{children}</a>;
23+
const downloadLink = getNodeDownloadUrl(
24+
versionWithPrefix,
25+
os,
26+
platform,
27+
kind
28+
);
29+
30+
return <LinkWithArrow href={downloadLink}>{children}</LinkWithArrow>;
2231
};
2332

2433
export default DownloadLink;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use client';
2+
3+
import type { FC, PropsWithChildren } from 'react';
4+
import { useContext } from 'react';
5+
6+
import DownloadLinkBase from '@/components/Downloads/DownloadLink';
7+
import { ReleaseContext } from '@/providers/releaseProvider';
8+
import type { DownloadKind } from '@/util/getNodeDownloadUrl';
9+
10+
type DownloadLinkProps = { kind?: DownloadKind };
11+
12+
const DownloadLink: FC<PropsWithChildren<DownloadLinkProps>> = ({
13+
kind = 'installer',
14+
children,
15+
}) => {
16+
const { release } = useContext(ReleaseContext);
17+
18+
return (
19+
<DownloadLinkBase release={release} kind={kind}>
20+
{children}
21+
</DownloadLinkBase>
22+
);
23+
};
24+
25+
export default DownloadLink;

apps/site/next.mdx.use.client.mjs

+16-13
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import DownloadButton from './components/Downloads/DownloadButton';
66
import DownloadLink from './components/Downloads/DownloadLink';
77
import BlogPostLink from './components/Downloads/Release/BlogPostLink';
88
import ChangelogLink from './components/Downloads/Release/ChangelogLink';
9-
import InstallationMethodDropdown from './components/Downloads/Release/InstallationMethodDropdown';
10-
import OperatingSystemDropdown from './components/Downloads/Release/OperatingSystemDropdown';
11-
import PackageManagerDropdown from './components/Downloads/Release/PackageManagerDropdown';
12-
import PlatformDropdown from './components/Downloads/Release/PlatformDropdown';
13-
import PrebuiltDownloadButtons from './components/Downloads/Release/PrebuiltDownloadButtons';
9+
import ReleaseDownloadLink from './components/Downloads/Release/DownloadLink';
10+
import ReleaseInstallationMethodDropdown from './components/Downloads/Release/InstallationMethodDropdown';
11+
import ReleaseOperatingSystemDropdown from './components/Downloads/Release/OperatingSystemDropdown';
12+
import ReleasePackageManagerDropdown from './components/Downloads/Release/PackageManagerDropdown';
13+
import ReleasePlatformDropdown from './components/Downloads/Release/PlatformDropdown';
14+
import ReleasePrebuiltDownloadButtons from './components/Downloads/Release/PrebuiltDownloadButtons';
1415
import ReleaseCodeBox from './components/Downloads/Release/ReleaseCodeBox';
15-
import VersionDropdown from './components/Downloads/Release/VersionDropdown';
16+
import ReleaseVersionDropdown from './components/Downloads/Release/VersionDropdown';
1617
import Link from './components/Link';
1718
import LinkWithArrow from './components/LinkWithArrow';
1819
import MDXCodeBox from './components/MDX/CodeBox';
@@ -44,23 +45,25 @@ export const clientMdxComponents = {
4445
// Provides an individual Node.js Release Context for Downloads
4546
Provider: ReleaseProvider,
4647
// Renders a drop-down menu to select a version
47-
VersionDropdown: VersionDropdown,
48+
VersionDropdown: ReleaseVersionDropdown,
4849
// Renders a drop-down menu to select a platform
49-
InstallationMethodDropdown: InstallationMethodDropdown,
50+
InstallationMethodDropdown: ReleaseInstallationMethodDropdown,
5051
// Renders a drop-down menu to select a package manager
51-
PackageManagerDropdown: PackageManagerDropdown,
52+
PackageManagerDropdown: ReleasePackageManagerDropdown,
5253
// Renders a drop-down menu to select a bitness
53-
PlatformDropdown: PlatformDropdown,
54+
PlatformDropdown: ReleasePlatformDropdown,
5455
// Renders a drop-down menu to select an operating system
55-
OperatingSystemDropdown: OperatingSystemDropdown,
56+
OperatingSystemDropdown: ReleaseOperatingSystemDropdown,
5657
// Renders a Blog Post Link for the selected release
5758
BlogPostLink: BlogPostLink,
5859
// Renders a Download Button for the selected release
59-
PrebuiltDownloadButtons: PrebuiltDownloadButtons,
60+
PrebuiltDownloadButtons: ReleasePrebuiltDownloadButtons,
6061
// Renders a Release CodeBox
6162
ReleaseCodeBox: ReleaseCodeBox,
62-
// Renders a Changelog Modal Link Button
63+
// Renders a Changelog Link Button
6364
ChangelogLink: ChangelogLink,
65+
// Renders a DownloadLink Button
66+
DownloadLink: ReleaseDownloadLink,
6467
},
6568
};
6669

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ Read the <Release.BlogPostLink>blog post</Release.BlogPostLink> for this version
2727

2828
Learn how to <LinkWithArrow href="https://github.com/nodejs/node#verifying-binaries">verify</LinkWithArrow> signed SHASUMS.
2929

30-
Learn how to <LinkWithArrow href="https://github.com/nodejs/node/blob/main/BUILDING.md#building-nodejs-on-supported-platforms">build Node.js</LinkWithArrow> from source.
30+
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="/about/previous-releases#looking-for-the-latest-release-of-a-version-branch">previous releases</Link>
33+
all <LinkWithArrow href="https://nodejs.org/download/release/">previous releases</LinkWithArrow>
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ Read the <Release.BlogPostLink>blog post</Release.BlogPostLink> for this version
2727

2828
Learn how to <LinkWithArrow href="https://github.com/nodejs/node#verifying-binaries">verify</LinkWithArrow> signed SHASUMS.
2929

30-
Learn how to <LinkWithArrow href="https://github.com/nodejs/node/blob/main/BUILDING.md#building-nodejs-on-supported-platforms">build Node.js</LinkWithArrow> from source.
30+
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="/about/previous-releases#looking-for-the-latest-release-of-a-version-branch">previous releases</Link>
33+
all <LinkWithArrow href="https://nodejs.org/download/release/">previous releases</LinkWithArrow>
3434
or the <LinkWithArrow href="https://unofficial-builds.nodejs.org/download/">unofficial</LinkWithArrow> binaries for other platforms.
3535

3636
</section>

apps/site/pages/en/index.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ layout: home
2222
<small>
2323
Downloads Node.js <b>{release.versionWithPrefix}</b>
2424
<sup title="Downloads a Node.js installer for your current platform">1</sup> with long-term support.
25-
Node.js can also be installed via <Link href="/download/package-manager">package managers</Link>.
25+
Node.js can also be installed via <Link href="/download">version managers</Link>.
2626
</small>
2727
</>
2828
)}

apps/site/util/getNodeDownloadUrl.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DIST_URL } from '@/next.constants.mjs';
22
import type { UserOS, UserPlatform } from '@/types/userOS';
33

4-
type DownloadKind = 'installer' | 'binary' | 'source';
4+
export type DownloadKind = 'installer' | 'binary' | 'source';
55

66
export const getNodeDownloadUrl = (
77
versionWithPrefix: string,

0 commit comments

Comments
 (0)