Skip to content

Commit 3628c11

Browse files
authored
feat: pills on footer and clean up code (#7999)
1 parent edacebc commit 3628c11

File tree

18 files changed

+95
-338
lines changed

18 files changed

+95
-338
lines changed

apps/site/components/Downloads/ReleaseModal/index.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type { FC } from 'react';
66
import { MinorReleasesTable } from '#site/components/Downloads/MinorReleasesTable';
77
import { ReleaseOverview } from '#site/components/Downloads/ReleaseOverview';
88
import Link from '#site/components/Link';
9-
import LinkWithArrow from '#site/components/LinkWithArrow';
109
import type { NodeRelease } from '#site/types';
1110

1211
type ReleaseModalProps = {
@@ -71,12 +70,6 @@ const ReleaseModal: FC<ReleaseModalProps> = ({
7170
<Title>{modalHeading}</Title>
7271

7372
<Content>
74-
{release.releaseAnnounceLink && (
75-
<LinkWithArrow href={release.releaseAnnounceLink}>
76-
{t('components.releaseModal.releaseAnnouncement')}
77-
</LinkWithArrow>
78-
)}
79-
8073
<ReleaseOverview release={release} />
8174

8275
<h5>{t('components.releaseModal.minorVersions')}</h5>

apps/site/components/withFooter.tsx

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
'use client';
2-
1+
import BadgeGroup from '@node-core/ui-components/Common/BadgeGroup';
32
import Footer from '@node-core/ui-components/Containers/Footer';
4-
import { useTranslations } from 'next-intl';
3+
import { getTranslations } from 'next-intl/server';
54
import type { FC } from 'react';
65

6+
import { getClientContext } from '#site/client-context';
77
import Link from '#site/components/Link';
8-
import { usePathname } from '#site/navigation.mjs';
98
import { siteNavigation } from '#site/next.json.mjs';
109

11-
const WithFooter: FC = () => {
12-
const t = useTranslations();
13-
const pathname = usePathname();
10+
import WithNodeRelease from './withNodeRelease';
11+
12+
const WithFooter: FC = async () => {
13+
const t = await getTranslations();
14+
const { pathname } = getClientContext();
1415

1516
const { socialLinks, footerLinks } = siteNavigation;
17+
1618
const updatedFooterLinks = footerLinks
1719
.slice(0, -1)
1820
.map(link => ({ ...link, text: t(link.text) }));
@@ -25,7 +27,43 @@ const WithFooter: FC = () => {
2527
footerLinks: updatedFooterLinks,
2628
};
2729

28-
return <Footer navigation={navigation} as={Link} pathname={pathname} />;
30+
const primary = (
31+
<>
32+
<WithNodeRelease status="Active LTS">
33+
{({ release }) => (
34+
<BadgeGroup
35+
size="small"
36+
kind="info"
37+
badgeText={release.versionWithPrefix}
38+
href={`/blog/release/${release.versionWithPrefix}`}
39+
>
40+
{t('components.containers.footer.releasePills.latestLTS')}
41+
</BadgeGroup>
42+
)}
43+
</WithNodeRelease>
44+
45+
<WithNodeRelease status="Current">
46+
{({ release }) => (
47+
<BadgeGroup
48+
size="small"
49+
badgeText={release.versionWithPrefix}
50+
href={`/blog/release/${release.versionWithPrefix}`}
51+
>
52+
{t('components.containers.footer.releasePills.latestRelease')}
53+
</BadgeGroup>
54+
)}
55+
</WithNodeRelease>
56+
</>
57+
);
58+
59+
return (
60+
<Footer
61+
navigation={navigation}
62+
as={Link}
63+
pathname={pathname}
64+
slots={{ primary }}
65+
/>
66+
);
2967
};
3068

3169
export default WithFooter;

apps/site/next-data/downloadSnippets.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import {
22
ENABLE_STATIC_EXPORT,
3-
NEXT_DATA_URL,
43
IS_NOT_VERCEL_RUNTIME_ENV,
4+
NEXT_DATA_URL,
55
} from '#site/next.constants.mjs';
66
import { availableLocaleCodes } from '#site/next.locales.mjs';
77
import type { DownloadSnippet } from '#site/types';
88

9-
export default async function getDownloadSnippets(
10-
lang: string
11-
): Promise<Array<DownloadSnippet>> {
9+
export default async function getDownloadSnippets(lang: string) {
1210
// Prevents attempting to retrieve data for an unsupported language as both the generator
1311
// and the API endpoint will simply return 404. And we want to prevent a 404 response.
1412
if (!availableLocaleCodes.includes(lang)) {
@@ -39,5 +37,6 @@ export default async function getDownloadSnippets(
3937
// Note: We do manual JSON.parse after response.text() to prevent React from throwing an Error
4038
// that does not provide a clear stack trace of which request is failing and what the JSON.parse error is
4139
const response = await fetch(fetchURL);
42-
return JSON.parse(await response.text());
40+
41+
return JSON.parse(await response.text()) as Array<DownloadSnippet>;
4342
}

apps/site/next-data/generators/downloadSnippets.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
'use strict';
22

3-
import { readFile } from 'node:fs/promises';
3+
import { readFile, glob } from 'node:fs/promises';
44
import { basename, extname, join } from 'node:path';
55

6-
import { glob } from 'glob';
7-
86
import { availableLocaleCodes } from '../../next.locales.mjs';
97

108
/**
@@ -20,11 +18,13 @@ export default async function generateDownloadSnippets() {
2018
const downloadSnippets = availableLocaleCodes.flatMap(async locale => {
2119
// We retrieve the full pathnames of all Blog Posts to read each file individually
2220
// Note that we get the files original language (Bash/PowerShell, etc)
23-
const filenames = await glob('**/*.bash', {
21+
const filenamesPromise = glob('**/*.bash', {
2422
root: process.cwd(),
2523
cwd: `snippets/${locale}/download`,
2624
});
2725

26+
const filenames = await Array.fromAsync(filenamesPromise);
27+
2828
// Creates the base path for the snippets for Node to read from
2929
const basePath = join(process.cwd(), `snippets/${locale}/download`);
3030

apps/site/next-data/generators/releaseData.mjs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
import nodevu from '@nodevu/core';
4-
import { glob } from 'glob';
54

65
// Gets the appropriate release status for each major release
76
const getNodeReleaseStatus = (now, support) => {
@@ -33,12 +32,6 @@ const getNodeReleaseStatus = (now, support) => {
3332
* @returns {Promise<Array<import('../../types').NodeRelease>>}
3433
*/
3534
const generateReleaseData = async () => {
36-
const releaseAnnouncements = await glob('**/*-release-announce.md', {
37-
root: process.cwd(),
38-
cwd: 'pages/en/blog/announcements/',
39-
absolute: false,
40-
});
41-
4235
const nodevuOutput = await nodevu({ fetch });
4336

4437
const majors = Object.entries(nodevuOutput).filter(
@@ -81,14 +74,6 @@ const generateReleaseData = async () => {
8174
releaseDate: release.releaseDate,
8275
}));
8376

84-
const majorVersion = latestVersion.semver.major;
85-
86-
const releaseAnnounceLink = releaseAnnouncements.includes(
87-
`v${majorVersion}-release-announce.md`
88-
)
89-
? `/blog/announcements/v${majorVersion}-release-announce`
90-
: undefined;
91-
9277
return {
9378
...support,
9479
status: status,
@@ -101,7 +86,6 @@ const generateReleaseData = async () => {
10186
v8: latestVersion.dependencies.v8,
10287
releaseDate: latestVersion.releaseDate,
10388
modules: latestVersion.modules.version || '',
104-
releaseAnnounceLink: releaseAnnounceLink,
10589
minorVersions: minorVersions,
10690
};
10791
});

apps/site/next.helpers.mjs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
'use strict';
22

3+
import { glob } from 'node:fs/promises';
34
import { fileURLToPath } from 'node:url';
45

5-
import { glob } from 'glob';
6-
76
/**
87
* We create a locale cache of Glob Promises
98
* to avoid reading the file system multiple times
@@ -37,7 +36,11 @@ export const getMarkdownFiles = async (root, cwd, ignore = []) => {
3736
const cacheKey = `${root}${cwd}${ignore.join('')}`;
3837

3938
if (!globCacheByPath.has(cacheKey)) {
40-
globCacheByPath.set(cacheKey, glob('**/*.{md,mdx}', { root, cwd, ignore }));
39+
const result = Array.fromAsync(
40+
glob('**/*.{md,mdx}', { root, cwd, ignore })
41+
);
42+
43+
globCacheByPath.set(cacheKey, result);
4144
}
4245

4346
return globCacheByPath.get(cacheKey);

apps/site/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
"cross-env": "catalog:",
5757
"feed": "~5.1.0",
5858
"github-slugger": "~2.0.0",
59-
"glob": "~11.0.1",
6059
"gray-matter": "~4.0.3",
6160
"next": "15.3.4",
6261
"next-intl": "~4.3.4",

apps/site/pages/en/index.mdx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@ layout: home
2626
<br />
2727
<small className="!text-xs">for Node.js 18 and below</small>
2828
</Button>
29-
30-
<div className="flex flex-col xs:flex-row gap-2 justify-center xs:mt-6">
31-
<WithNodeRelease status="Active LTS">
32-
{({ release }) =>
33-
<BadgeGroup size="small" kind="info" badgeText={release.versionWithPrefix} href={`/blog/release/${release.versionWithPrefix}`}>
34-
Latest LTS
35-
</BadgeGroup>}
36-
</WithNodeRelease>
37-
38-
<WithNodeRelease status="Current">
39-
{({ release }) =>
40-
<BadgeGroup size="small" badgeText={release.versionWithPrefix} href={`/blog/release/${release.versionWithPrefix}`}>
41-
Latest Release
42-
</BadgeGroup>}
43-
</WithNodeRelease>
44-
</div>
45-
46-
<span className="italic text-center text-xs! text-neutral-800 dark:text-neutral-600">"LTS" refers to the long-term support version of Node.js. <Link href="/about/previous-releases">Learn more about Node.js releases.</Link></span>
4729
</div>
4830

4931
</div>

apps/site/pages/fr/index.mdx

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)