Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/site/app/[locale]/next-data/api-data/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import provideReleaseData from '#site/next-data/providers/releaseData';
import { GITHUB_API_KEY } from '#site/next.constants.mjs';
import { defaultLocale } from '#site/next.locales.mjs';
import type { GitHubApiFile } from '#site/types';
import { getGitHubApiDocsUrl } from '#site/util/gitHubUtils';
import { parseRichTextIntoPlainText } from '#site/util/stringUtils';
import { getGitHubApiDocsUrl } from '#site/util/github';
import { parseRichTextIntoPlainText } from '#site/util/string';

// Defines if we should use the GitHub API Key for the request
// based on the environment variable `GITHUB_API_KEY`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ import { ImageResponse } from 'next/og';

import { DEFAULT_CATEGORY_OG_TYPE } from '#site/next.constants.mjs';
import { defaultLocale } from '#site/next.locales.mjs';
import { hexToRGBA } from '#site/util/hexToRGBA';

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

type Category = keyof typeof CATEGORY_TO_THEME_COLOUR_MAP;

type DynamicStaticPaths = { locale: string; category: Category; title: string };
type StaticParams = { params: Promise<DynamicStaticPaths> };
type StaticParams = {
params: Promise<{
locale: string;
category: keyof typeof CATEGORY_TO_THEME_COLOUR_MAP;
title: string;
}>;
};

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

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

return new ImageResponse(
(
Expand Down
2 changes: 1 addition & 1 deletion apps/site/app/[locale]/next-data/page-data/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import matter from 'gray-matter';

import { dynamicRouter } from '#site/next.dynamic.mjs';
import { defaultLocale } from '#site/next.locales.mjs';
import { parseRichTextIntoPlainText } from '#site/util/stringUtils';
import { parseRichTextIntoPlainText } from '#site/util/string';

// This is the Route Handler for the `GET` method which handles the request
// for a digest and metadata of all existing pages on Node.js Website
Expand Down
2 changes: 1 addition & 1 deletion apps/site/client-context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cache } from 'react';

import type { ClientSharedServerContext } from '#site/types';
import { assignClientContext } from '#site/util/assignClientContext';
import { assignClientContext } from '#site/util/context';

// This allows us to have Server-Side Context's of the shared "contextual" data
// which includes the frontmatter, the current pathname from the dynamic segments
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/Blog/BlogPostCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import FormattedTime from '#site/components/Common/FormattedTime';
import Link from '#site/components/Link';
import WithAvatarGroup from '#site/components/withAvatarGroup';
import type { BlogCategory } from '#site/types';
import { mapBlogCategoryToPreviewType } from '#site/util/blogUtils';
import { mapBlogCategoryToPreviewType } from '#site/util/blog';

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

Expand Down
4 changes: 2 additions & 2 deletions apps/site/components/Downloads/DownloadButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type { FC, PropsWithChildren } from 'react';
import Button from '#site/components/Common/Button';
import { useClientContext } from '#site/hooks';
import type { NodeRelease } from '#site/types';
import { getNodeDownloadUrl } from '#site/util/getNodeDownloadUrl';
import { getUserPlatform } from '#site/util/getUserPlatform';
import { getNodeDownloadUrl } from '#site/util/url';
import { getUserPlatform } from '#site/util/userAgent';

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

Expand Down
7 changes: 3 additions & 4 deletions apps/site/components/Downloads/DownloadLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import type { FC, PropsWithChildren } from 'react';

import LinkWithArrow from '#site/components/LinkWithArrow';
import { useClientContext } from '#site/hooks';
import type { NodeRelease } from '#site/types';
import type { DownloadKind } from '#site/util/getNodeDownloadUrl';
import { getNodeDownloadUrl } from '#site/util/getNodeDownloadUrl';
import { getUserPlatform } from '#site/util/getUserPlatform';
import type { DownloadKind, NodeRelease } from '#site/types';
import { getNodeDownloadUrl } from '#site/util/url';
import { getUserPlatform } from '#site/util/userAgent';

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

Expand Down
4 changes: 2 additions & 2 deletions apps/site/components/Downloads/MinorReleasesTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { FC } from 'react';
import Link from '#site/components/Link';
import { BASE_CHANGELOG_URL } from '#site/next.constants.mjs';
import type { MinorVersion } from '#site/types';
import { getNodeApiLink } from '#site/util/getNodeApiLink';
import { getNodeApiUrl } from '#site/util/url';

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

Expand Down Expand Up @@ -50,7 +50,7 @@ export const MinorReleasesTable: FC<MinorReleasesTableProps> = ({
<Separator orientation="vertical" />
<Link
kind="neutral"
href={getNodeApiLink(`v${release.version}`)}
href={getNodeApiUrl(`v${release.version}`)}
>
{t('actions.docs')}
</Link>
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/Downloads/Release/DownloadLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useContext } from 'react';

import DownloadLinkBase from '#site/components/Downloads/DownloadLink';
import { ReleaseContext } from '#site/providers/releaseProvider';
import type { DownloadKind } from '#site/util/getNodeDownloadUrl';
import type { DownloadKind } from '#site/types/download';

type DownloadLinkProps = { kind?: DownloadKind };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import type { FC } from 'react';

import { ReleaseContext } from '#site/providers/releaseProvider';
import type { InstallationMethod } from '#site/types/release';
import {
nextItem,
INSTALL_METHODS,
parseCompat,
} from '#site/util/downloadUtils';
import { nextItem, INSTALL_METHODS, parseCompat } from '#site/util/download';

const InstallationMethodDropdown: FC = () => {
const release = useContext(ReleaseContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ import type { FC } from 'react';

import { useClientContext } from '#site/hooks';
import { ReleaseContext } from '#site/providers/releaseProvider';
import type { UserOS } from '#site/types/userOS';
import {
nextItem,
OPERATING_SYSTEMS,
parseCompat,
} from '#site/util/downloadUtils';
import type { OperatingSystem } from '#site/types/userAgent';
import { nextItem, OPERATING_SYSTEMS, parseCompat } from '#site/util/download';

type OperatingSystemDropdownProps = { exclude?: Array<UserOS> };
type OperatingSystemDropdownProps = { exclude?: Array<OperatingSystem> };

const OperatingSystemDropdown: FC<OperatingSystemDropdownProps> = () => {
const { os } = useClientContext();
Expand Down Expand Up @@ -53,7 +49,7 @@ const OperatingSystemDropdown: FC<OperatingSystemDropdownProps> = () => {
);

return (
<Select<UserOS>
<Select<OperatingSystem>
values={parsedOperatingSystems}
defaultValue={release.os !== 'LOADING' ? release.os : undefined}
loading={release.os === 'LOADING'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import type { FC } from 'react';

import { ReleaseContext } from '#site/providers/releaseProvider';
import type { PackageManager } from '#site/types/release';
import {
nextItem,
PACKAGE_MANAGERS,
parseCompat,
} from '#site/util/downloadUtils';
import { nextItem, PACKAGE_MANAGERS, parseCompat } from '#site/util/download';

const PackageManagerDropdown: FC = () => {
const release = useContext(ReleaseContext);
Expand Down
8 changes: 4 additions & 4 deletions apps/site/components/Downloads/Release/PlatformDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { useEffect, useContext, useMemo } from 'react';

import { useClientContext } from '#site/hooks';
import { ReleaseContext } from '#site/providers/releaseProvider';
import type { UserPlatform } from '#site/types/userOS';
import { PLATFORMS, nextItem, parseCompat } from '#site/util/downloadUtils';
import { getUserPlatform } from '#site/util/getUserPlatform';
import type { Platform } from '#site/types/userAgent';
import { PLATFORMS, nextItem, parseCompat } from '#site/util/download';
import { getUserPlatform } from '#site/util/userAgent';

const PlatformDropdown: FC = () => {
const { architecture, bitness } = useClientContext();
Expand Down Expand Up @@ -57,7 +57,7 @@ const PlatformDropdown: FC = () => {
);

return (
<Select<UserPlatform>
<Select<Platform>
values={parsedPlatforms}
defaultValue={release.platform !== '' ? release.platform : undefined}
loading={release.os === 'LOADING' || release.platform === ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { ReleaseContext } from '#site/providers/releaseProvider';
import {
OS_NOT_SUPPORTING_INSTALLERS,
OperatingSystemLabel,
} from '#site/util/downloadUtils';
import { getNodeDownloadUrl } from '#site/util/getNodeDownloadUrl';
} from '#site/util/download';
import { getNodeDownloadUrl } from '#site/util/url';

// Retrieves the pure extension piece from the input string
const getExtension = (input: string) => String(input.split('.').slice(-1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ReleasesContext,
} from '#site/providers/releaseProvider';
import type { ReleaseContextType } from '#site/types/release';
import { INSTALL_METHODS } from '#site/util/downloadUtils';
import { INSTALL_METHODS } from '#site/util/download';

// Creates a minimal JavaScript interpreter for parsing the JavaScript code from the snippets
// Note: that the code runs inside a sandboxed environment and cannot interact with any code outside of the sandbox
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/withAvatarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ComponentProps, FC } from 'react';

import Link from '#site/components/Link';
import type { AuthorProps } from '#site/types';
import { getAuthors } from '#site/util/authorUtils';
import { getAuthors } from '#site/util/author';

type WithAvatarGroupProps = Omit<
ComponentProps<typeof AvatarGroup>,
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/withBadgeGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { FC } from 'react';

import Link from '#site/components/Link';
import { siteConfig } from '#site/next.json.mjs';
import { dateIsBetween } from '#site/util/dateUtils';
import { dateIsBetween } from '#site/util/date';

const WithBadgeGroup: FC<{ section: string }> = ({ section }) => {
const badge = siteConfig.websiteBadges[section];
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/withBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { FC } from 'react';

import Link from '#site/components/Link';
import { siteConfig } from '#site/next.json.mjs';
import { dateIsBetween } from '#site/util/dateUtils';
import { dateIsBetween } from '#site/util/date';

const WithBanner: FC<{ section: string }> = ({ section }) => {
const banner = siteConfig.websiteBanners[section];
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/withBlogCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import BlogPostCard from '#site/components/Blog/BlogPostCard';
import LinkTabs from '#site/components/Common/LinkTabs';
import Pagination from '#site/components/Common/Pagination';
import type { BlogPostsRSC } from '#site/types';
import { mapAuthorToCardAuthors } from '#site/util/authorUtils';
import { mapAuthorToCardAuthors } from '#site/util/author';

type WithBlogCategoriesProps = {
categories: ComponentProps<typeof LinkTabs>['tabs'];
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/withBreadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
useSiteNavigation,
} from '#site/hooks';
import type { NavigationKeys } from '#site/types';
import { dashToCamelCase } from '#site/util/stringUtils';
import { dashToCamelCase } from '#site/util/string';

type WithBreadcrumbsProps = {
navKeys?: Array<NavigationKeys>;
Expand Down
2 changes: 1 addition & 1 deletion apps/site/components/withMetaBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useMediaQuery from '#site/hooks/react-client/useMediaQuery';
import { DEFAULT_DATE_FORMAT } from '#site/next.calendar.constants.mjs';
import { TRANSLATION_URL } from '#site/next.constants.mjs';
import { defaultLocale } from '#site/next.locales.mjs';
import { getGitHubBlobUrl } from '#site/util/gitHubUtils';
import { getGitHubBlobUrl } from '#site/util/github';

const WithMetaBar: FC = () => {
const { headings, readingTime, frontmatter, filename } = useClientContext();
Expand Down
19 changes: 11 additions & 8 deletions apps/site/hooks/react-client/useDetectOS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import { useEffect, useState } from 'react';

import type { UserArchitecture, UserBitness, UserOS } from '#site/types/userOS';
import { detectOS } from '#site/util/detectOS';
import { getHighEntropyValues } from '#site/util/getHighEntropyValues';
import type {
Architecture,
Bitness,
OperatingSystem,
} from '#site/types/userAgent';
import { getHighEntropyValues, detectOS } from '#site/util/userAgent';

type UserOSState = {
os: UserOS | 'LOADING';
bitness: UserBitness | '';
architecture: UserArchitecture | '';
os: OperatingSystem | 'LOADING';
bitness: Bitness | '';
architecture: Architecture | '';
};

const useDetectOS = () => {
Expand Down Expand Up @@ -42,8 +45,8 @@ const useDetectOS = () => {
}) => {
setUserOSState(current => ({
...current,
bitness: bitness as UserBitness,
architecture: architecture as UserArchitecture,
bitness: bitness as Bitness,
architecture: architecture as Architecture,
}));
}
);
Expand Down
2 changes: 1 addition & 1 deletion apps/site/hooks/react-client/useNavigationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { RefObject } from 'react';
import { useContext, useEffect } from 'react';

import { NavigationStateContext } from '#site/providers/navigationStateProvider';
import { debounce } from '#site/util/debounce';
import { debounce } from '#site/util/objects';

const useNavigationState = <T extends HTMLElement>(
id: string,
Expand Down
2 changes: 1 addition & 1 deletion apps/site/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getRequestConfig } from 'next-intl/server';

import { availableLocaleCodes, defaultLocale } from '#site/next.locales.mjs';

import deepMerge from './util/deepMerge';
import { deepMerge } from './util/objects';

// Loads the Application Locales/Translations Dynamically
const loadLocaleDictionary = async (locale: string) => {
Expand Down
4 changes: 2 additions & 2 deletions apps/site/layouts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import WithFooter from '#site/components/withFooter';
import WithMetaBar from '#site/components/withMetaBar';
import WithNavBar from '#site/components/withNavBar';
import { useClientContext } from '#site/hooks/react-server';
import { mapAuthorToCardAuthors } from '#site/util/authorUtils';
import { mapBlogCategoryToPreviewType } from '#site/util/blogUtils';
import { mapAuthorToCardAuthors } from '#site/util/author';
import { mapBlogCategoryToPreviewType } from '#site/util/blog';

import styles from './layouts.module.css';

Expand Down
2 changes: 1 addition & 1 deletion apps/site/next.mdx.compiler.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { matter } from 'vfile-matter';

import { createSval } from './next.jsx.compiler.mjs';
import { REHYPE_PLUGINS, REMARK_PLUGINS } from './next.mdx.plugins.mjs';
import { createGitHubSlugger } from './util/gitHubUtils';
import { createGitHubSlugger } from './util/github';

// Defines a JSX Fragment and JSX Runtime for the MDX Compiler
export const reactRuntime = { Fragment, jsx, jsxs };
Expand Down
2 changes: 1 addition & 1 deletion apps/site/providers/matterProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { FC, PropsWithChildren } from 'react';

import { useDetectOS } from '#site/hooks';
import type { ClientSharedServerContext } from '#site/types';
import { assignClientContext } from '#site/util/assignClientContext';
import { assignClientContext } from '#site/util/context';

export const MatterContext = createContext<ClientSharedServerContext>(
assignClientContext({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export interface DownloadSnippet {
language: string;
content: string;
}

export type DownloadKind = 'installer' | 'binary' | 'source';
3 changes: 2 additions & 1 deletion apps/site/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export * from './server';
export * from './github';
export * from './calendar';
export * from './author';
export * from './downloads';
export * from './download';
export * from './userAgent';
Loading
Loading