Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
22 changes: 12 additions & 10 deletions apps/site/app/[locale]/next-data/og/[category]/[title]/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,34 @@ 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
// @see https://nextjs.org/docs/app/building-your-application/routing/router-handlers
export const GET = async (_: Request, props: StaticParams) => {
const params = await props.params;

const categoryColour =
const categoryColor =
params.category in CATEGORY_TO_THEME_COLOUR_MAP
? 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, ${categoryColor}, 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/download';
import { getUserPlatform } from '#site/util/userAgent';

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

Expand Down
5 changes: 2 additions & 3 deletions apps/site/components/Downloads/DownloadLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ 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 { getNodeDownloadUrl, type DownloadKind } from '#site/util/download';
import { getUserPlatform } from '#site/util/userAgent';

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

Expand Down
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 { getNodeApiLink } from '#site/util/api';

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

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/util/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 @@ -8,11 +8,7 @@ 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 { nextItem, OPERATING_SYSTEMS, parseCompat } from '#site/util/download';

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

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
4 changes: 2 additions & 2 deletions apps/site/components/Downloads/Release/PlatformDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ 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 { PLATFORMS, nextItem, parseCompat } from '#site/util/download';
import { getUserPlatform } from '#site/util/userAgent';

const PlatformDropdown: FC = () => {
const { architecture, bitness } = useClientContext();
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';
getNodeDownloadUrl,
} from '#site/util/download';

// 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
3 changes: 1 addition & 2 deletions apps/site/hooks/react-client/useDetectOS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
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 { getHighEntropyValues, detectOS } from '#site/util/userAgent';

type UserOSState = {
os: UserOS | 'LOADING';
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/misc';

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/misc';

// 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
2 changes: 1 addition & 1 deletion apps/site/types/userOS.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type constants from '../util/downloadUtils/constants.json';
import type constants from '../util/download/constants.json';

// Extract OS key type from the systems object
export type UserOS = keyof typeof constants.systems;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { getNodeApiLink } from '#site/util/getNodeApiLink';
import { getNodeApiLink } from '#site/util/api';

describe('getNodeApiLink', () => {
it('should return the correct API link for versions >=0.3.1 and <0.5.1', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getAuthorWithId,
getAuthorWithName,
getAuthors,
} from '#site/util/authorUtils';
} from '#site/util/author';

describe('mapAuthorToCardAuthors', () => {
it('maps authors to card authors with default avatar source', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { mapBlogCategoryToPreviewType } from '#site/util/blogUtils';
import { mapBlogCategoryToPreviewType } from '#site/util/blog';

describe('mapBlogCategoryToPreviewType', () => {
it('returns the correct preview type for recognized categories', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';

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

const mockContext = {
frontmatter: { title: 'Sample Title' },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { dateIsBetween } from '#site/util/dateUtils';
import { dateIsBetween } from '#site/util/date';

describe('dateIsBetween', () => {
it('should return true when the current date is between start and end dates', () => {
Expand Down
20 changes: 0 additions & 20 deletions apps/site/util/__tests__/deepMerge.test.mjs

This file was deleted.

Loading
Loading