From 380affe8d14a5006bf26af91f1af12fd4ead536d Mon Sep 17 00:00:00 2001 From: Claudio Wunder Date: Wed, 5 Jul 2023 17:41:41 +0200 Subject: [PATCH 1/6] fix: fixed localized links and next links redirection --- .eslintrc | 19 ------------------- .../Downloads/DownloadReleasesTable.tsx | 3 +-- .../DownloadToggle/index.module.scss | 6 ++++-- components/Home/Banner.tsx | 5 ++--- components/Home/HomeDownloadButton.tsx | 13 +++++++------ components/LocalizedLink.tsx | 19 ++++++++----------- .../__snapshots__/index.stories.tsx.snap | 2 +- components/Sections/NewHeader/index.tsx | 9 +++++---- pages/_app.tsx | 3 ++- 9 files changed, 30 insertions(+), 49 deletions(-) diff --git a/.eslintrc b/.eslintrc index 46e9a31da0300..0f5fd7d42380e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,25 +6,6 @@ "plugin:storybook/recommended" ], "overrides": [ - { - "files": ["**/*.{mjs,js,ts,tsx}"], - "rules": { - "import/order": [ - "warn", - { - "groups": [ - "builtin", - "external", - "internal", - "sibling", - "parent", - "index", - "type" - ] - } - ] - } - }, { "files": ["**/*.ts?(x)"], "plugins": ["@typescript-eslint"], diff --git a/components/Downloads/DownloadReleasesTable.tsx b/components/Downloads/DownloadReleasesTable.tsx index 01b74cd21a9a9..d35fe9a94341b 100644 --- a/components/Downloads/DownloadReleasesTable.tsx +++ b/components/Downloads/DownloadReleasesTable.tsx @@ -1,5 +1,4 @@ import { FormattedMessage } from 'react-intl'; -import Link from 'next/link'; import { getNodejsChangelog } from '../../util/getNodeJsChangelog'; import { getNodeApiLink } from '../../util/getNodeApiLink'; import { useNodeReleases } from '../../hooks/useNodeReleases'; @@ -18,7 +17,7 @@ const DownloadReleasesTable: FC = () => { V8 npm - NODE_MODULE_VERSION[1] + NODE_MODULE_VERSION[1] diff --git a/components/Downloads/DownloadToggle/index.module.scss b/components/Downloads/DownloadToggle/index.module.scss index 1e2b2cc2ef6ae..ebebd39ef1250 100644 --- a/components/Downloads/DownloadToggle/index.module.scss +++ b/components/Downloads/DownloadToggle/index.module.scss @@ -28,7 +28,8 @@ background: var(--black0); border: none; border-radius: 32px; - box-shadow: inset 1px -1px 1px rgba(0, 0, 0, 0.08), + box-shadow: + inset 1px -1px 1px rgba(0, 0, 0, 0.08), inset 0px 1px 2px rgba(0, 0, 0, 0.08); box-sizing: border-box; color: var(--black7); @@ -44,7 +45,8 @@ width: 133px; &.current { - box-shadow: inset 1px -1px 1px rgba(0, 0, 0, 0.08), + box-shadow: + inset 1px -1px 1px rgba(0, 0, 0, 0.08), inset 0px 1px 2px rgba(0, 0, 0, 0.08); margin-left: -30px; } diff --git a/components/Home/Banner.tsx b/components/Home/Banner.tsx index 748e804e6b7d9..5ecfebaa7badd 100644 --- a/components/Home/Banner.tsx +++ b/components/Home/Banner.tsx @@ -1,4 +1,3 @@ -import Link from 'next/link'; import { useSiteConfig } from '../../hooks/useSiteConfig'; import { dateIsBetween } from '../../util/dateIsBetween'; @@ -17,14 +16,14 @@ const Banner = () => { if (showBanner && indexBanner.text) { return (

- {indexBanner.text} + {indexBanner.text}

); } if (showBanner && indexBanner.html) { return ( - diff --git a/components/Home/HomeDownloadButton.tsx b/components/Home/HomeDownloadButton.tsx index 7d927a7f44d0b..109d0fe87c137 100644 --- a/components/Home/HomeDownloadButton.tsx +++ b/components/Home/HomeDownloadButton.tsx @@ -21,9 +21,10 @@ const HomeDownloadButton: FC = ({ const nodeDownloadLink = downloadUrlByOS(versionWithPrefix, os, bitness); const nodeApiLink = `https://nodejs.org/dist/latest-v${major}.x/docs/api/`; const nodeAllDownloadsLink = `/download${isLts ? '/' : '/current'}`; - const nodeDownloadTitle = - `${labels?.download} ${version}` + - ` ${labels?.[isLts ? 'lts' : 'current']}`; + + const nodeDownloadTitle = `${labels?.download} ${version} ${labels?.[ + isLts ? 'lts' : 'current' + ]}`; return (
@@ -44,12 +45,12 @@ const HomeDownloadButton: FC = ({
  • - + {labels?.changelog} - +
  • - {labels?.api} + {labels?.api}
  • diff --git a/components/LocalizedLink.tsx b/components/LocalizedLink.tsx index d7600ab47cb1e..f62b8f518ade1 100644 --- a/components/LocalizedLink.tsx +++ b/components/LocalizedLink.tsx @@ -1,4 +1,3 @@ -import { useMemo } from 'react'; import Link from 'next/link'; import { useLocale } from '../hooks/useLocale'; import { linkWithLocale } from '../util/linkWithLocale'; @@ -11,18 +10,16 @@ const LocalizedLink: FC> = ({ }) => { const { currentLocale } = useLocale(); - const localizedUrl = linkWithLocale(currentLocale.code); - - const finalHref = useMemo( - () => - /^https?:\/\//.test(href.toString()) - ? href.toString() - : localizedUrl(href), - [href, localizedUrl] - ); + if (/^https?:\/\//.test(href.toString())) { + return ( + + {children} + + ); + } return ( - + {children} ); diff --git a/components/Sections/NewHeader/__snapshots__/index.stories.tsx.snap b/components/Sections/NewHeader/__snapshots__/index.stories.tsx.snap index e86866cd2973c..5b9605b44c525 100644 --- a/components/Sections/NewHeader/__snapshots__/index.stories.tsx.snap +++ b/components/Sections/NewHeader/__snapshots__/index.stories.tsx.snap @@ -7,7 +7,7 @@ exports[`Sections/NewHeader Default smoke-test 1`] = `
    diff --git a/components/Sections/NewHeader/index.tsx b/components/Sections/NewHeader/index.tsx index f0d9cc7320d23..93985acc766f3 100644 --- a/components/Sections/NewHeader/index.tsx +++ b/components/Sections/NewHeader/index.tsx @@ -1,18 +1,19 @@ import { FormattedMessage } from 'react-intl'; import Image from 'next/image'; -import Link from 'next/link'; import { FaGithub } from 'react-icons/fa'; -import styles from './index.module.scss'; +import LocalizedLink from '../../LocalizedLink'; import ActiveLocalizedLink from '../../Common/ActiveLocalizedLink'; import DarkModeToggle from '../../Common/DarkModeToggle'; import LanguageSelector from '../../Common/LanguageSelector'; import type { FC } from 'react'; +import styles from './index.module.scss'; + const Header: FC = () => (