diff --git a/hooks/useNodeReleases.ts b/hooks/useNodeReleases.ts index 26a170c112a04..b4fb137fa70b3 100644 --- a/hooks/useNodeReleases.ts +++ b/hooks/useNodeReleases.ts @@ -12,5 +12,10 @@ export const useNodeReleases = () => { [releases] ); - return { releases, getReleaseByStatus }; + const getLatestIsLtsRelease = useCallback( + () => releases.find(release => release.isLts), + [releases] + ); + + return { releases, getReleaseByStatus, getLatestIsLtsRelease }; }; diff --git a/layouts/DocsLayout.tsx b/layouts/DocsLayout.tsx index 1b2a470c93fe4..7d865cb627adb 100644 --- a/layouts/DocsLayout.tsx +++ b/layouts/DocsLayout.tsx @@ -7,11 +7,11 @@ import { useNodeReleases } from '@/hooks/useNodeReleases'; import BaseLayout from './BaseLayout'; const DocsLayout: FC = ({ children }) => { - const { getReleaseByStatus } = useNodeReleases(); + const { getReleaseByStatus, getLatestIsLtsRelease } = useNodeReleases(); const [lts, current] = useMemo( - () => [getReleaseByStatus('Active LTS'), getReleaseByStatus('Current')], - [getReleaseByStatus] + () => [getLatestIsLtsRelease(), getReleaseByStatus('Current')], + [getLatestIsLtsRelease, getReleaseByStatus] ); const translationContext = { diff --git a/layouts/DownloadLayout.tsx b/layouts/DownloadLayout.tsx index 91926f87697e9..57b5cf1293f50 100644 --- a/layouts/DownloadLayout.tsx +++ b/layouts/DownloadLayout.tsx @@ -23,7 +23,7 @@ const DownloadLayout: FC = ({ children }) => { {children} - + {({ release }) => ( <> diff --git a/layouts/IndexLayout.tsx b/layouts/IndexLayout.tsx index 062610f322808..5fa28e93b3e40 100644 --- a/layouts/IndexLayout.tsx +++ b/layouts/IndexLayout.tsx @@ -47,7 +47,7 @@ const IndexLayout: FC = ({ children }) => {

{downloadHeadText}

- + {({ release }) => } diff --git a/next.json.mjs b/next.json.mjs index c57999bad576d..62551f2e99758 100644 --- a/next.json.mjs +++ b/next.json.mjs @@ -3,7 +3,15 @@ import localeConfig from './i18n/config.json' assert { type: 'json' }; import siteNavigation from './navigation.json' assert { type: 'json' }; import blogData from './public/blog-posts-data.json' assert { type: 'json' }; +import releaseData from './public/node-releases-data.json' assert { type: 'json' }; import siteRedirects from './redirects.json' assert { type: 'json' }; import siteConfig from './site.json' assert { type: 'json' }; -export { siteConfig, siteNavigation, siteRedirects, localeConfig, blogData }; +export { + siteConfig, + siteNavigation, + siteRedirects, + localeConfig, + blogData, + releaseData, +}; diff --git a/providers/nodeReleasesProvider.tsx b/providers/nodeReleasesProvider.tsx index cc539f64c1f43..c8dbafb3514c8 100644 --- a/providers/nodeReleasesProvider.tsx +++ b/providers/nodeReleasesProvider.tsx @@ -1,7 +1,7 @@ import { createContext, useMemo } from 'react'; import type { FC, PropsWithChildren } from 'react'; -import nodeReleasesData from '@/public/node-releases-data.json'; +import { releaseData } from '@/next.json.mjs'; import type { NodeReleaseSource, NodeRelease } from '@/types'; import { getNodeReleaseStatus } from '@/util/nodeRelease'; @@ -11,7 +11,7 @@ export const NodeReleasesProvider: FC = ({ children }) => { const releases = useMemo(() => { const now = new Date(); - return nodeReleasesData.map((raw: NodeReleaseSource) => { + return releaseData.map((raw: NodeReleaseSource) => { const support = { currentStart: raw.currentStart, ltsStart: raw.ltsStart, diff --git a/providers/withNodeRelease.tsx b/providers/withNodeRelease.tsx index 276eea04a31ed..4f9296bf009c0 100644 --- a/providers/withNodeRelease.tsx +++ b/providers/withNodeRelease.tsx @@ -6,7 +6,7 @@ import type { NodeRelease, NodeReleaseStatus } from '@/types'; import { isNodeRelease } from '@/util/nodeRelease'; type WithNodeReleaseProps = { - status: NodeReleaseStatus; + status: NodeReleaseStatus[] | NodeReleaseStatus; children: FC<{ release: NodeRelease }>; }; @@ -16,8 +16,12 @@ export const WithNodeRelease: FC = ({ }) => { const { getReleaseByStatus } = useNodeReleases(); - const release = useMemo( - () => getReleaseByStatus(status), + const [release] = useMemo( + () => + [status] + .flat() + .map(s => getReleaseByStatus(s)) + .filter(s => !!s), [status, getReleaseByStatus] );