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
10 changes: 2 additions & 8 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@

DIR=$(cd `dirname $0` && pwd -P)

# resets the node release data file
echo "[]" > $DIR/../public/node-releases-data.json

# resets the blog post data file
echo "{ \"pagination\": [], \"categories\": [], \"posts\": [] }" > $DIR/../public/blog-posts-data.json

# adds these changes to be part of the current commit
git add --sparse $DIR/../public/node-releases-data.json
git add --sparse $DIR/../public/blog-posts-data.json
git checkout $DIR/../public/node-releases-data.json
git checkout $DIR/../public/blog-posts-data.json

# lint and format staged files
npx lint-staged
7 changes: 3 additions & 4 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// TODO: Convert this to ESM once the bug is resolved
// https://github.com/storybookjs/test-runner/issues/293
import type { TestRunnerConfig } from '@storybook/test-runner';

const config = {
const config: TestRunnerConfig = {
async postRender(page, _context) {
const rootElementId = '[data-test-id="story-root"]';
const rootElement = await page.locator(rootElementId);
Expand All @@ -11,4 +10,4 @@ const config = {
},
};

module.exports = config;
export default config;
2 changes: 1 addition & 1 deletion app/en/feed/[feed]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextResponse } from 'next/server';
import * as nextJson from '@/next.json.mjs';
import * as nextData from '@/next-data/index.mjs';
import * as nextData from '@/next.data.mjs';

// loads all the data from the blog-posts-data.json file
const websiteFeeds = nextData.generateWebsiteFeeds(nextJson.blogData);
Expand Down
6 changes: 0 additions & 6 deletions components/Article/Codebox/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import { IntlProvider } from 'react-intl';

import Codebox, { replaceLabelLanguages, replaceLanguages } from '../index';

jest.mock('isomorphic-dompurify', () => {
return {
sanitize: jest.fn().mockImplementation(source => source),
};
});

describe('Replacer tests', (): void => {
it('replaceLabelLanguages', (): void => {
expect(replaceLabelLanguages('language-console')).toBe('language-bash');
Expand Down
3 changes: 1 addition & 2 deletions components/Article/Codebox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react';
import { FormattedMessage } from 'react-intl';
import { highlight, languages } from 'prismjs';
import { sanitize } from 'isomorphic-dompurify';
import classnames from 'classnames';
import styles from './index.module.scss';
import { useCopyToClipboard } from '../../../hooks/useCopyToClipboard';
Expand Down Expand Up @@ -46,7 +45,7 @@ const Codebox: FC<CodeBoxProps> = ({ children: { props } }) => {
const prismLanguage = languages[parsedLanguage] || languages.text;

setParsedCode(
sanitize(highlight(codeArray[langIndex], prismLanguage, parsedLanguage))
highlight(codeArray[langIndex], prismLanguage, parsedLanguage)
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [langIndex]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ exports[`Common/Banner WithHTMLImage smoke-test 1`] = `
target="_blank"
rel="noopener noreferrer"
>
<img alt="Banner Image"
src="/static/images/nodejs-training.png"
<img src="/static/images/nodejs-training.png"
alt="Banner Image"
>
</a>
</div>
Expand Down
4 changes: 0 additions & 4 deletions components/Common/Banner/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import { IntlProvider } from 'react-intl';
import Banner from '../index';
import type { WebsiteBanner } from '../../../../types';

jest.mock('isomorphic-dompurify', () => ({
sanitize: jest.fn((html: string) => html),
}));

const bannersIndex: WebsiteBanner = {
endDate: '',
link: 'test/banner/link',
Expand Down
3 changes: 1 addition & 2 deletions components/Common/Banner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useMemo } from 'react';
import { useIntl } from 'react-intl';
import { sanitize } from 'isomorphic-dompurify';
import styles from './index.module.scss';
import { dateIsBetween } from '../../../util/dateIsBetween';
import { isAbsoluteUrl } from '../../../util/isAbsoluteUrl';
Expand Down Expand Up @@ -36,7 +35,7 @@ const useHtmlContent = ({ html, link }: WebsiteBanner) =>
href={link}
target="_blank"
rel="noopener noreferrer"
dangerouslySetInnerHTML={{ __html: sanitize(html) }}
dangerouslySetInnerHTML={{ __html: html }}
/>
);
}
Expand Down
3 changes: 1 addition & 2 deletions layouts/DownloadReleasesLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMemo } from 'react';
import { sanitize } from 'isomorphic-dompurify';
import BaseLayout from './BaseLayout';
import { useLayoutContext } from '../hooks/useLayoutContext';
import DownloadReleasesTable from '../components/Downloads/DownloadReleasesTable';
Expand All @@ -14,7 +13,7 @@ const DownloadReleasesLayout: FC<PropsWithChildren> = ({ children }) => {
// @TODO: Remove this once we migrate to `nodejs/nodejs.dev` codebase as this is unsafe
// And completely not recommended
const extraModulesContent = useMemo(
() => sanitize(`[<a href="#backref-1">1</a>]: ${modules}`),
() => `[<a href="#backref-1">1</a>]: ${modules}`,
[modules]
);

Expand Down
6 changes: 3 additions & 3 deletions next-data/generateBlogPostsData.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';

import { readFile, writeFile } from 'node:fs/promises';
import { basename, dirname, extname, join } from 'node:path';
import { basename, extname, join } from 'node:path';
import graymatter from 'gray-matter';
import * as helpers from './helpers.mjs';
import * as nextHelpers from '../next.helpers.mjs';

// gets the current blog path based on local module path
const blogPath = join(process.cwd(), 'pages/en/blog');
Expand Down Expand Up @@ -51,7 +51,7 @@ const getFrontMatter = (filename, source) => {
*/
const generateBlogPostsData = async () => {
// we retrieve all the filenames of all blog posts
const filenames = await helpers.getMarkdownFiles(
const filenames = await nextHelpers.getMarkdownFiles(
process.cwd(),
'pages/en/blog',
['**/index.md', '**/pagination.md']
Expand Down
13 changes: 0 additions & 13 deletions next-data/index.mjs

This file was deleted.

6 changes: 6 additions & 0 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ const nextConfig = {
distDir: nextConstants.ENABLE_STATIC_EXPORT ? 'build' : '.next',
output: nextConstants.ENABLE_STATIC_EXPORT ? 'export' : undefined,
experimental: {
swcMinify: true,
legacyBrowsers: false,
nextScriptWorkers: true,
webpackBuildWorker: true,
largePageDataBytes: 128 * 100000,
swcPlugins: [['next-superjson-plugin', {}]],
outputFileTracingExcludes: {
'*': ['./public/**', 'node_modules/**/@swc/core*'],
},
},
};

Expand Down
11 changes: 11 additions & 0 deletions next.data.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

import generateWebsiteFeeds from './next-data/generateWebsiteFeeds.mjs';
import generateBlogPostsData from './next-data/generateBlogPostsData.mjs';
import generateNodeReleasesJson from './next-data/generateNodeReleasesJson.mjs';

export {
generateWebsiteFeeds,
generateBlogPostsData,
generateNodeReleasesJson,
};
5 changes: 2 additions & 3 deletions next.dynamic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import remarkGfm from 'remark-gfm';
import { serialize } from 'next-mdx-remote/serialize';
import * as nextLocales from './next.locales.mjs';
import * as nextConstants from './next.constants.mjs';
import * as nextData from './next-data/index.mjs';
import * as nextHelpers from './next.helpers.mjs';

// allows us to run a glob to get markdown files based on a language folder
const getPathsByLanguage = async (
locale = nextConstants.DEFAULT_LOCALE_CODE,
ignored = []
) =>
nextData.helpers.getMarkdownFiles(process.cwd(), `pages/${locale}`, ignored);
) => nextHelpers.getMarkdownFiles(process.cwd(), `pages/${locale}`, ignored);

/**
* This method is responsible for generating a Collection of all available paths that
Expand Down
1 change: 0 additions & 1 deletion next-data/helpers.mjs → next.helpers.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';

import { existsSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { glob } from 'glob';

Expand Down
Loading