From 7efa770b871f62d743c0f3d3f611d8677429677a Mon Sep 17 00:00:00 2001 From: Claudio W Date: Tue, 28 Jan 2025 18:30:00 -0800 Subject: [PATCH] chore: better links for source (#7428) * chore: better links for source * chore: addressed feedback --- .../components/Downloads/DownloadLink.tsx | 15 ++++++++-- .../Downloads/Release/DownloadLink.tsx | 25 ++++++++++++++++ apps/site/next.mdx.use.client.mjs | 29 ++++++++++--------- apps/site/pages/en/download/current.mdx | 4 +-- apps/site/pages/en/download/index.mdx | 4 +-- apps/site/pages/en/index.mdx | 2 +- apps/site/util/getNodeDownloadUrl.ts | 2 +- 7 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 apps/site/components/Downloads/Release/DownloadLink.tsx diff --git a/apps/site/components/Downloads/DownloadLink.tsx b/apps/site/components/Downloads/DownloadLink.tsx index c4cc62402b7e1..df9fc74c5e7ab 100644 --- a/apps/site/components/Downloads/DownloadLink.tsx +++ b/apps/site/components/Downloads/DownloadLink.tsx @@ -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> = ({ release: { versionWithPrefix }, + kind = 'installer', children, }) => { const { os, bitness, architecture } = useClientContext(); const platform = getUserPlatform(architecture, bitness); - const downloadLink = getNodeDownloadUrl(versionWithPrefix, os, platform); - return {children}; + const downloadLink = getNodeDownloadUrl( + versionWithPrefix, + os, + platform, + kind + ); + + return {children}; }; export default DownloadLink; diff --git a/apps/site/components/Downloads/Release/DownloadLink.tsx b/apps/site/components/Downloads/Release/DownloadLink.tsx new file mode 100644 index 0000000000000..40b43abb80648 --- /dev/null +++ b/apps/site/components/Downloads/Release/DownloadLink.tsx @@ -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> = ({ + kind = 'installer', + children, +}) => { + const { release } = useContext(ReleaseContext); + + return ( + + {children} + + ); +}; + +export default DownloadLink; diff --git a/apps/site/next.mdx.use.client.mjs b/apps/site/next.mdx.use.client.mjs index 88d11389a9ec9..64584887b2a7a 100644 --- a/apps/site/next.mdx.use.client.mjs +++ b/apps/site/next.mdx.use.client.mjs @@ -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'; @@ -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, }, }; diff --git a/apps/site/pages/en/download/current.mdx b/apps/site/pages/en/download/current.mdx index b1d9f2b646828..471b38d940478 100644 --- a/apps/site/pages/en/download/current.mdx +++ b/apps/site/pages/en/download/current.mdx @@ -27,10 +27,10 @@ Read the blog post for this version Learn how to verify signed SHASUMS. -Learn how to build Node.js from source. +Looking for Node.js source? Download a signed Node.js source tarball. Check out our nightly binaries or -all previous releases +all previous releases or the unofficial binaries for other platforms. diff --git a/apps/site/pages/en/download/index.mdx b/apps/site/pages/en/download/index.mdx index b1d9f2b646828..471b38d940478 100644 --- a/apps/site/pages/en/download/index.mdx +++ b/apps/site/pages/en/download/index.mdx @@ -27,10 +27,10 @@ Read the blog post for this version Learn how to verify signed SHASUMS. -Learn how to build Node.js from source. +Looking for Node.js source? Download a signed Node.js source tarball. Check out our nightly binaries or -all previous releases +all previous releases or the unofficial binaries for other platforms. diff --git a/apps/site/pages/en/index.mdx b/apps/site/pages/en/index.mdx index c3307276a6bb0..1558dac0319aa 100644 --- a/apps/site/pages/en/index.mdx +++ b/apps/site/pages/en/index.mdx @@ -22,7 +22,7 @@ layout: home Downloads Node.js {release.versionWithPrefix} 1 with long-term support. - Node.js can also be installed via package managers. + Node.js can also be installed via version managers. )} diff --git a/apps/site/util/getNodeDownloadUrl.ts b/apps/site/util/getNodeDownloadUrl.ts index 9775c4c675188..6b4fc34935cd0 100644 --- a/apps/site/util/getNodeDownloadUrl.ts +++ b/apps/site/util/getNodeDownloadUrl.ts @@ -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,