Skip to content

Commit b582b77

Browse files
authored
chore(site): rename and merge utilities (#7853)
* chore(site): rename and merge utilities * ua -> userAgent * fixup! ua -> userAgent * code review * fixup! code review * code review
1 parent 7d8b9c5 commit b582b77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+356
-384
lines changed

apps/site/app/[locale]/next-data/api-data/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import provideReleaseData from '#site/next-data/providers/releaseData';
44
import { GITHUB_API_KEY } from '#site/next.constants.mjs';
55
import { defaultLocale } from '#site/next.locales.mjs';
66
import type { GitHubApiFile } from '#site/types';
7-
import { getGitHubApiDocsUrl } from '#site/util/gitHubUtils';
8-
import { parseRichTextIntoPlainText } from '#site/util/stringUtils';
7+
import { getGitHubApiDocsUrl } from '#site/util/github';
8+
import { parseRichTextIntoPlainText } from '#site/util/string';
99

1010
// Defines if we should use the GitHub API Key for the request
1111
// based on the environment variable `GITHUB_API_KEY`

apps/site/app/[locale]/next-data/og/[category]/[title]/route.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,21 @@ import { ImageResponse } from 'next/og';
44

55
import { DEFAULT_CATEGORY_OG_TYPE } from '#site/next.constants.mjs';
66
import { defaultLocale } from '#site/next.locales.mjs';
7-
import { hexToRGBA } from '#site/util/hexToRGBA';
87

98
// TODO: use CSS variables instead of absolute values
109
const CATEGORY_TO_THEME_COLOUR_MAP = {
11-
announcement: '#1a3f1d',
12-
release: '#0c7bb3',
13-
vulnerability: '#ae5f00',
10+
announcement: 'rgb(26, 63, 29)',
11+
release: 'rgb(12, 123, 179)',
12+
vulnerability: 'rgb(174, 95, 0)',
1413
};
1514

16-
type Category = keyof typeof CATEGORY_TO_THEME_COLOUR_MAP;
17-
18-
type DynamicStaticPaths = { locale: string; category: Category; title: string };
19-
type StaticParams = { params: Promise<DynamicStaticPaths> };
15+
type StaticParams = {
16+
params: Promise<{
17+
locale: string;
18+
category: keyof typeof CATEGORY_TO_THEME_COLOUR_MAP;
19+
title: string;
20+
}>;
21+
};
2022

2123
// This is the Route Handler for the `GET` method which handles the request
2224
// for generating OpenGraph images for Blog Posts and Pages
@@ -29,7 +31,7 @@ export const GET = async (_: Request, props: StaticParams) => {
2931
? CATEGORY_TO_THEME_COLOUR_MAP[params.category]
3032
: CATEGORY_TO_THEME_COLOUR_MAP[DEFAULT_CATEGORY_OG_TYPE];
3133

32-
const gridBackground = `radial-gradient(circle, ${hexToRGBA(categoryColour)}, transparent)`;
34+
const gridBackground = `radial-gradient(circle, ${categoryColour}, transparent)`;
3335

3436
return new ImageResponse(
3537
(

apps/site/app/[locale]/next-data/page-data/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import matter from 'gray-matter';
44

55
import { dynamicRouter } from '#site/next.dynamic.mjs';
66
import { defaultLocale } from '#site/next.locales.mjs';
7-
import { parseRichTextIntoPlainText } from '#site/util/stringUtils';
7+
import { parseRichTextIntoPlainText } from '#site/util/string';
88

99
// This is the Route Handler for the `GET` method which handles the request
1010
// for a digest and metadata of all existing pages on Node.js Website

apps/site/client-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { cache } from 'react';
22

33
import type { ClientSharedServerContext } from '#site/types';
4-
import { assignClientContext } from '#site/util/assignClientContext';
4+
import { assignClientContext } from '#site/util/context';
55

66
// This allows us to have Server-Side Context's of the shared "contextual" data
77
// which includes the frontmatter, the current pathname from the dynamic segments

apps/site/components/Blog/BlogPostCard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import FormattedTime from '#site/components/Common/FormattedTime';
66
import Link from '#site/components/Link';
77
import WithAvatarGroup from '#site/components/withAvatarGroup';
88
import type { BlogCategory } from '#site/types';
9-
import { mapBlogCategoryToPreviewType } from '#site/util/blogUtils';
9+
import { mapBlogCategoryToPreviewType } from '#site/util/blog';
1010

1111
import styles from './index.module.css';
1212

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { FC, PropsWithChildren } from 'react';
77
import Button from '#site/components/Common/Button';
88
import { useClientContext } from '#site/hooks';
99
import type { NodeRelease } from '#site/types';
10-
import { getNodeDownloadUrl } from '#site/util/getNodeDownloadUrl';
11-
import { getUserPlatform } from '#site/util/getUserPlatform';
10+
import { getNodeDownloadUrl } from '#site/util/url';
11+
import { getUserPlatform } from '#site/util/userAgent';
1212

1313
import styles from './index.module.css';
1414

apps/site/components/Downloads/DownloadLink.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import type { FC, PropsWithChildren } from 'react';
44

55
import LinkWithArrow from '#site/components/LinkWithArrow';
66
import { useClientContext } from '#site/hooks';
7-
import type { NodeRelease } from '#site/types';
8-
import type { DownloadKind } from '#site/util/getNodeDownloadUrl';
9-
import { getNodeDownloadUrl } from '#site/util/getNodeDownloadUrl';
10-
import { getUserPlatform } from '#site/util/getUserPlatform';
7+
import type { DownloadKind, NodeRelease } from '#site/types';
8+
import { getNodeDownloadUrl } from '#site/util/url';
9+
import { getUserPlatform } from '#site/util/userAgent';
1110

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { FC } from 'react';
77
import Link from '#site/components/Link';
88
import { BASE_CHANGELOG_URL } from '#site/next.constants.mjs';
99
import type { MinorVersion } from '#site/types';
10-
import { getNodeApiLink } from '#site/util/getNodeApiLink';
10+
import { getNodeApiUrl } from '#site/util/url';
1111

1212
import styles from './index.module.css';
1313

@@ -50,7 +50,7 @@ export const MinorReleasesTable: FC<MinorReleasesTableProps> = ({
5050
<Separator orientation="vertical" />
5151
<Link
5252
kind="neutral"
53-
href={getNodeApiLink(`v${release.version}`)}
53+
href={getNodeApiUrl(`v${release.version}`)}
5454
>
5555
{t('actions.docs')}
5656
</Link>

apps/site/components/Downloads/Release/DownloadLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useContext } from 'react';
55

66
import DownloadLinkBase from '#site/components/Downloads/DownloadLink';
77
import { ReleaseContext } from '#site/providers/releaseProvider';
8-
import type { DownloadKind } from '#site/util/getNodeDownloadUrl';
8+
import type { DownloadKind } from '#site/types/download';
99

1010
type DownloadLinkProps = { kind?: DownloadKind };
1111

apps/site/components/Downloads/Release/InstallationMethodDropdown.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import type { FC } from 'react';
77

88
import { ReleaseContext } from '#site/providers/releaseProvider';
99
import type { InstallationMethod } from '#site/types/release';
10-
import {
11-
nextItem,
12-
INSTALL_METHODS,
13-
parseCompat,
14-
} from '#site/util/downloadUtils';
10+
import { nextItem, INSTALL_METHODS, parseCompat } from '#site/util/download';
1511

1612
const InstallationMethodDropdown: FC = () => {
1713
const release = useContext(ReleaseContext);

0 commit comments

Comments
 (0)