Skip to content

Commit

Permalink
chore: better links for source (nodejs#7428)
Browse files Browse the repository at this point in the history
* chore: better links for source

* chore: addressed feedback
  • Loading branch information
ovflowd authored Jan 29, 2025
1 parent 6fed09a commit 7efa770
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 22 deletions.
15 changes: 12 additions & 3 deletions apps/site/components/Downloads/DownloadLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,32 @@

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

import LinkWithArrow from '@/components/LinkWithArrow';
import { useClientContext } from '@/hooks';
import type { NodeRelease } from '@/types';
import type { DownloadKind } from '@/util/getNodeDownloadUrl';
import { getNodeDownloadUrl } from '@/util/getNodeDownloadUrl';
import { getUserPlatform } from '@/util/getUserPlatform';

type DownloadLinkProps = { release: NodeRelease };
type DownloadLinkProps = { release: NodeRelease; kind?: DownloadKind };

const DownloadLink: FC<PropsWithChildren<DownloadLinkProps>> = ({
release: { versionWithPrefix },
kind = 'installer',
children,
}) => {
const { os, bitness, architecture } = useClientContext();

const platform = getUserPlatform(architecture, bitness);
const downloadLink = getNodeDownloadUrl(versionWithPrefix, os, platform);

return <a href={downloadLink}>{children}</a>;
const downloadLink = getNodeDownloadUrl(
versionWithPrefix,
os,
platform,
kind
);

return <LinkWithArrow href={downloadLink}>{children}</LinkWithArrow>;
};

export default DownloadLink;
25 changes: 25 additions & 0 deletions apps/site/components/Downloads/Release/DownloadLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use client';

import type { FC, PropsWithChildren } from 'react';
import { useContext } from 'react';

import DownloadLinkBase from '@/components/Downloads/DownloadLink';
import { ReleaseContext } from '@/providers/releaseProvider';
import type { DownloadKind } from '@/util/getNodeDownloadUrl';

type DownloadLinkProps = { kind?: DownloadKind };

const DownloadLink: FC<PropsWithChildren<DownloadLinkProps>> = ({
kind = 'installer',
children,
}) => {
const { release } = useContext(ReleaseContext);

return (
<DownloadLinkBase release={release} kind={kind}>
{children}
</DownloadLinkBase>
);
};

export default DownloadLink;
29 changes: 16 additions & 13 deletions apps/site/next.mdx.use.client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import DownloadButton from './components/Downloads/DownloadButton';
import DownloadLink from './components/Downloads/DownloadLink';
import BlogPostLink from './components/Downloads/Release/BlogPostLink';
import ChangelogLink from './components/Downloads/Release/ChangelogLink';
import InstallationMethodDropdown from './components/Downloads/Release/InstallationMethodDropdown';
import OperatingSystemDropdown from './components/Downloads/Release/OperatingSystemDropdown';
import PackageManagerDropdown from './components/Downloads/Release/PackageManagerDropdown';
import PlatformDropdown from './components/Downloads/Release/PlatformDropdown';
import PrebuiltDownloadButtons from './components/Downloads/Release/PrebuiltDownloadButtons';
import ReleaseDownloadLink from './components/Downloads/Release/DownloadLink';
import ReleaseInstallationMethodDropdown from './components/Downloads/Release/InstallationMethodDropdown';
import ReleaseOperatingSystemDropdown from './components/Downloads/Release/OperatingSystemDropdown';
import ReleasePackageManagerDropdown from './components/Downloads/Release/PackageManagerDropdown';
import ReleasePlatformDropdown from './components/Downloads/Release/PlatformDropdown';
import ReleasePrebuiltDownloadButtons from './components/Downloads/Release/PrebuiltDownloadButtons';
import ReleaseCodeBox from './components/Downloads/Release/ReleaseCodeBox';
import VersionDropdown from './components/Downloads/Release/VersionDropdown';
import ReleaseVersionDropdown from './components/Downloads/Release/VersionDropdown';
import Link from './components/Link';
import LinkWithArrow from './components/LinkWithArrow';
import MDXCodeBox from './components/MDX/CodeBox';
Expand Down Expand Up @@ -44,23 +45,25 @@ export const clientMdxComponents = {
// Provides an individual Node.js Release Context for Downloads
Provider: ReleaseProvider,
// Renders a drop-down menu to select a version
VersionDropdown: VersionDropdown,
VersionDropdown: ReleaseVersionDropdown,
// Renders a drop-down menu to select a platform
InstallationMethodDropdown: InstallationMethodDropdown,
InstallationMethodDropdown: ReleaseInstallationMethodDropdown,
// Renders a drop-down menu to select a package manager
PackageManagerDropdown: PackageManagerDropdown,
PackageManagerDropdown: ReleasePackageManagerDropdown,
// Renders a drop-down menu to select a bitness
PlatformDropdown: PlatformDropdown,
PlatformDropdown: ReleasePlatformDropdown,
// Renders a drop-down menu to select an operating system
OperatingSystemDropdown: OperatingSystemDropdown,
OperatingSystemDropdown: ReleaseOperatingSystemDropdown,
// Renders a Blog Post Link for the selected release
BlogPostLink: BlogPostLink,
// Renders a Download Button for the selected release
PrebuiltDownloadButtons: PrebuiltDownloadButtons,
PrebuiltDownloadButtons: ReleasePrebuiltDownloadButtons,
// Renders a Release CodeBox
ReleaseCodeBox: ReleaseCodeBox,
// Renders a Changelog Modal Link Button
// Renders a Changelog Link Button
ChangelogLink: ChangelogLink,
// Renders a DownloadLink Button
DownloadLink: ReleaseDownloadLink,
},
};

Expand Down
4 changes: 2 additions & 2 deletions apps/site/pages/en/download/current.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Read the <Release.BlogPostLink>blog post</Release.BlogPostLink> for this version

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

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.
Looking for Node.js source? Download a signed <Release.DownloadLink kind="source">Node.js source</Release.DownloadLink> tarball.

Check out our <LinkWithArrow href="https://nodejs.org/download/nightly/">nightly</LinkWithArrow> binaries or
all <Link href="/about/previous-releases#looking-for-the-latest-release-of-a-version-branch">previous releases</Link>
all <LinkWithArrow href="https://nodejs.org/download/release/">previous releases</LinkWithArrow>
or the <LinkWithArrow href="https://unofficial-builds.nodejs.org/download/">unofficial</LinkWithArrow> binaries for other platforms.

</section>
4 changes: 2 additions & 2 deletions apps/site/pages/en/download/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Read the <Release.BlogPostLink>blog post</Release.BlogPostLink> for this version

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

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.
Looking for Node.js source? Download a signed <Release.DownloadLink kind="source">Node.js source</Release.DownloadLink> tarball.

Check out our <LinkWithArrow href="https://nodejs.org/download/nightly/">nightly</LinkWithArrow> binaries or
all <Link href="/about/previous-releases#looking-for-the-latest-release-of-a-version-branch">previous releases</Link>
all <LinkWithArrow href="https://nodejs.org/download/release/">previous releases</LinkWithArrow>
or the <LinkWithArrow href="https://unofficial-builds.nodejs.org/download/">unofficial</LinkWithArrow> binaries for other platforms.

</section>
2 changes: 1 addition & 1 deletion apps/site/pages/en/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ layout: home
<small>
Downloads Node.js <b>{release.versionWithPrefix}</b>
<sup title="Downloads a Node.js installer for your current platform">1</sup> with long-term support.
Node.js can also be installed via <Link href="/download/package-manager">package managers</Link>.
Node.js can also be installed via <Link href="/download">version managers</Link>.
</small>
</>
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/site/util/getNodeDownloadUrl.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DIST_URL } from '@/next.constants.mjs';
import type { UserOS, UserPlatform } from '@/types/userOS';

type DownloadKind = 'installer' | 'binary' | 'source';
export type DownloadKind = 'installer' | 'binary' | 'source';

export const getNodeDownloadUrl = (
versionWithPrefix: string,
Expand Down

0 comments on commit 7efa770

Please sign in to comment.