Skip to content

Commit 15a4d18

Browse files
committed
chore: fixed vars, next-intl, etc
1 parent ec14c64 commit 15a4d18

File tree

16 files changed

+39
-59
lines changed

16 files changed

+39
-59
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"editor.formatOnSave": true,
44
"editor.defaultFormatter": "esbenp.prettier-vscode",
55
"javascript.updateImportsOnFileMove.enabled": "always",
6-
"typescript.updateImportsOnFileMove.enabled": "always"
6+
"typescript.updateImportsOnFileMove.enabled": "always",
7+
"typescript.tsdk": "node_modules/typescript/lib"
78
}

apps/site/app/[locale]/[[...path]]/page.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { setContext, setTags } from '@sentry/nextjs';
22
import { notFound, redirect } from 'next/navigation';
3-
import { unstable_setRequestLocale } from 'next-intl/server';
3+
import { setRequestLocale } from 'next-intl/server';
44
import type { FC } from 'react';
55

66
import { setClientContext } from '@/client-context';
77
import { MDXRenderer } from '@/components/mdxRenderer';
88
import WithLayout from '@/components/withLayout';
9-
import { ENABLE_STATIC_EXPORT, VERCEL_REVALIDATE } from '@/next.constants.mjs';
9+
import { ENABLE_STATIC_EXPORT } from '@/next.constants.mjs';
1010
import { PAGE_VIEWPORT, DYNAMIC_ROUTES } from '@/next.dynamic.constants.mjs';
1111
import { dynamicRouter } from '@/next.dynamic.mjs';
1212
import {
@@ -72,7 +72,7 @@ const getPage: FC<DynamicParams> = async props => {
7272

7373
if (!availableLocaleCodes.includes(locale)) {
7474
// Forces the current locale to be the Default Locale
75-
unstable_setRequestLocale(defaultLocale.code);
75+
setRequestLocale(defaultLocale.code);
7676

7777
if (!allLocaleCodes.includes(locale)) {
7878
// when the locale is not listed in the locales, return NotFound
@@ -85,7 +85,7 @@ const getPage: FC<DynamicParams> = async props => {
8585
}
8686

8787
// Configures the current Locale to be the given Locale of the Request
88-
unstable_setRequestLocale(locale);
88+
setRequestLocale(locale);
8989

9090
// Gets the current full pathname for a given path
9191
const pathname = dynamicRouter.getPathname(path);
@@ -181,6 +181,6 @@ export const dynamic = 'force-static';
181181
// Ensures that this endpoint is invalidated and re-executed every X minutes
182182
// so that when new deployments happen, the data is refreshed
183183
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
184-
export const revalidate = VERCEL_REVALIDATE;
184+
export const revalidate = 300;
185185

186186
export default getPage;

apps/site/app/[locale]/feed/[feed]/route.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { NextResponse } from 'next/server';
22

33
import provideWebsiteFeeds from '@/next-data/providers/websiteFeeds';
4-
import { VERCEL_REVALIDATE } from '@/next.constants.mjs';
54
import { siteConfig } from '@/next.json.mjs';
65
import { defaultLocale } from '@/next.locales.mjs';
76

@@ -44,4 +43,4 @@ export const dynamic = 'force-static';
4443
// Ensures that this endpoint is invalidated and re-executed every X minutes
4544
// so that when new deployments happen, the data is refreshed
4645
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
47-
export const revalidate = VERCEL_REVALIDATE;
46+
export const revalidate = 300;

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { deflateSync } from 'node:zlib';
22

33
import provideReleaseData from '@/next-data/providers/releaseData';
4-
import { GITHUB_API_KEY, VERCEL_REVALIDATE } from '@/next.constants.mjs';
4+
import { GITHUB_API_KEY } from '@/next.constants.mjs';
55
import { defaultLocale } from '@/next.locales.mjs';
66
import type { GitHubApiFile } from '@/types';
77
import { getGitHubApiDocsUrl } from '@/util/gitHubUtils';
@@ -77,4 +77,4 @@ export const dynamic = 'error';
7777
// Ensures that this endpoint is invalidated and re-executed every X minutes
7878
// so that when new deployments happen, the data is refreshed
7979
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
80-
export const revalidate = VERCEL_REVALIDATE;
80+
export const revalidate = 300;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
provideBlogPosts,
44
providePaginatedBlogPosts,
55
} from '@/next-data/providers/blogData';
6-
import { VERCEL_REVALIDATE } from '@/next.constants.mjs';
76
import { defaultLocale } from '@/next.locales.mjs';
87

98
type StaticParams = {
@@ -66,4 +65,4 @@ export const dynamic = 'error';
6665
// Ensures that this endpoint is invalidated and re-executed every X minutes
6766
// so that when new deployments happen, the data is refreshed
6867
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
69-
export const revalidate = VERCEL_REVALIDATE;
68+
export const revalidate = 300;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { provideChangelogData } from '@/next-data/providers/changelogData';
22
import provideReleaseData from '@/next-data/providers/releaseData';
3-
import { VERCEL_REVALIDATE } from '@/next.constants.mjs';
43
import { defaultLocale } from '@/next.locales.mjs';
54

65
type StaticParams = {
@@ -43,4 +42,4 @@ export const dynamic = 'error';
4342
// Ensures that this endpoint is invalidated and re-executed every X minutes
4443
// so that when new deployments happen, the data is refreshed
4544
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
46-
export const revalidate = VERCEL_REVALIDATE;
45+
export const revalidate = 300;

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

+2-10
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@ import { ImageResponse } from 'next/og';
22

33
import HexagonGrid from '@/components/Icons/HexagonGrid';
44
import JsIconWhite from '@/components/Icons/Logos/JsIconWhite';
5-
import {
6-
ENABLE_STATIC_EXPORT,
7-
VERCEL_ENV,
8-
VERCEL_REVALIDATE,
9-
} from '@/next.constants.mjs';
5+
import { ENABLE_STATIC_EXPORT, VERCEL_ENV } from '@/next.constants.mjs';
106
import { defaultLocale } from '@/next.locales.mjs';
117
import tailwindConfig from '@/tailwind.config';
128
import { hexToRGBA } from '@/util/hexToRGBA';
@@ -60,10 +56,6 @@ export const generateStaticParams = async () => [
6056
{ locale: defaultLocale.code },
6157
];
6258

63-
// We want to use `edge` runtime when using Vercel
64-
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#runtime
65-
export const runtime = VERCEL_ENV ? 'edge' : 'nodejs';
66-
6759
// In this case we want to catch-all possible requests. This ensures that we always generate and
6860
// serve the OpenGrapgh images independently on the locale
6961
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamicparams
@@ -76,4 +68,4 @@ export const dynamic = ENABLE_STATIC_EXPORT ? 'force-static' : 'auto';
7668
// Ensures that this endpoint is invalidated and re-executed every X minutes
7769
// so that when new deployments happen, the data is refreshed
7870
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
79-
export const revalidate = VERCEL_REVALIDATE;
71+
export const revalidate = 300;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { deflateSync } from 'node:zlib';
22

33
import matter from 'gray-matter';
44

5-
import { VERCEL_REVALIDATE } from '@/next.constants.mjs';
65
import { dynamicRouter } from '@/next.dynamic.mjs';
76
import { defaultLocale } from '@/next.locales.mjs';
87
import { parseRichTextIntoPlainText } from '@/util/stringUtils';
@@ -69,4 +68,4 @@ export const dynamic = 'error';
6968
// Ensures that this endpoint is invalidated and re-executed every X minutes
7069
// so that when new deployments happen, the data is refreshed
7170
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
72-
export const revalidate = VERCEL_REVALIDATE;
71+
export const revalidate = 300;

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import provideReleaseData from '@/next-data/providers/releaseData';
2-
import { VERCEL_REVALIDATE } from '@/next.constants.mjs';
32
import { defaultLocale } from '@/next.locales.mjs';
43

54
// This is the Route Handler for the `GET` method which handles the request
@@ -29,4 +28,4 @@ export const dynamic = 'error';
2928
// Ensures that this endpoint is invalidated and re-executed every X minutes
3029
// so that when new deployments happen, the data is refreshed
3130
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate
32-
export const revalidate = VERCEL_REVALIDATE;
31+
export const revalidate = 300;

apps/site/i18n.tsx

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { importLocale } from '@node-core/website-i18n';
22
import { getRequestConfig } from 'next-intl/server';
33

4-
import { availableLocaleCodes } from '@/next.locales.mjs';
4+
import { availableLocaleCodes, defaultLocale } from '@/next.locales.mjs';
55

66
import deepMerge from './util/deepMerge';
77

@@ -13,7 +13,7 @@ const loadLocaleDictionary = async (locale: string) => {
1313
'@node-core/website-i18n/locales/en.json'
1414
).then(f => f.default);
1515

16-
if (locale === 'en') {
16+
if (locale === defaultLocale.code) {
1717
return defaultMessages;
1818
}
1919

@@ -30,9 +30,14 @@ const loadLocaleDictionary = async (locale: string) => {
3030
};
3131

3232
// Provides `next-intl` configuration for RSC/SSR
33-
export default getRequestConfig(async ({ locale }) => ({
34-
// This is the dictionary of messages to be loaded
35-
messages: await loadLocaleDictionary(locale),
36-
// We always define the App timezone as UTC
37-
timeZone: 'Etc/UTC',
38-
}));
33+
export default getRequestConfig(async ({ requestLocale }) => {
34+
// Awaits for resolving the Request Locale
35+
const locale = await requestLocale;
36+
37+
return {
38+
// This is the dictionary of messages to be loaded
39+
messages: await loadLocaleDictionary(locale ?? defaultLocale.code),
40+
// We always define the App timezone as UTC
41+
timeZone: 'Etc/UTC',
42+
};
43+
});

apps/site/navigation.mjs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use strict';
22

3-
import { createSharedPathnamesNavigation } from 'next-intl/navigation';
3+
import { createNavigation } from 'next-intl/navigation';
44

55
import { availableLocaleCodes } from './next.locales.mjs';
66

7-
export const { Link, redirect, usePathname, useRouter } =
8-
createSharedPathnamesNavigation({ locales: availableLocaleCodes });
7+
export const { Link, redirect, usePathname, useRouter } = createNavigation({
8+
locales: availableLocaleCodes,
9+
});

apps/site/next.constants.mjs

-10
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ export const IS_DEVELOPMENT = process.env.NODE_ENV === 'development';
1414
*/
1515
export const VERCEL_ENV = process.env.NEXT_PUBLIC_VERCEL_ENV || undefined;
1616

17-
/**
18-
* This is used for defining a default time of when `next-data` and other dynamically generated
19-
* but static-enabled pages should be regenerated.
20-
*
21-
* Note that this is a custom Environment Variable that can be defined by us when necessary
22-
*/
23-
export const VERCEL_REVALIDATE = Number(
24-
process.env.NEXT_PUBLIC_VERCEL_REVALIDATE_TIME || 300
25-
);
26-
2717
/**
2818
* This is used for telling Next.js to do a Static Export Build of the Website
2919
*

apps/site/next.json.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
22

3-
import _authors from './authors.json' assert { type: 'json' };
4-
import _siteNavigation from './navigation.json' assert { type: 'json' };
5-
import _siteRedirects from './redirects.json' assert { type: 'json' };
6-
import _siteConfig from './site.json' assert { type: 'json' };
3+
import _authors from './authors.json' with { type: 'json' };
4+
import _siteNavigation from './navigation.json' with { type: 'json' };
5+
import _siteRedirects from './redirects.json' with { type: 'json' };
6+
import _siteConfig from './site.json' with { type: 'json' };
77

88
/** @type {Record<string, import('./types').Author>} */
99
export const authors = _authors;

apps/site/pages/en/blog/release/v16.14.0.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This release adds experimental support for the import assertions stage 3 proposa
1515
To keep Node.js ESM implementation as compatible as possible with the HTML spec, import assertions are now required to import JSON modules (still behind the `--experimental-json-modules` CLI flag):
1616

1717
```mjs
18-
import info from `./package.json` assert { type: `json` };
18+
import info from `./package.json` with { type: `json` };
1919
```
2020

2121
Or use dynamic import:

apps/site/turbo.json

-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"NEXT_PUBLIC_BASE_PATH",
1717
"NEXT_PUBLIC_ORAMA_API_KEY",
1818
"NEXT_PUBLIC_ORAMA_ENDPOINT",
19-
"NEXT_PUBLIC_VERCEL_REVALIDATE_TIME",
2019
"NEXT_PUBLIC_DATA_URL"
2120
]
2221
},
@@ -40,7 +39,6 @@
4039
"NEXT_PUBLIC_BASE_PATH",
4140
"NEXT_PUBLIC_ORAMA_API_KEY",
4241
"NEXT_PUBLIC_ORAMA_ENDPOINT",
43-
"NEXT_PUBLIC_VERCEL_REVALIDATE_TIME",
4442
"NEXT_PUBLIC_DATA_URL"
4543
]
4644
},
@@ -57,7 +55,6 @@
5755
"NEXT_PUBLIC_BASE_PATH",
5856
"NEXT_PUBLIC_ORAMA_API_KEY",
5957
"NEXT_PUBLIC_ORAMA_ENDPOINT",
60-
"NEXT_PUBLIC_VERCEL_REVALIDATE_TIME",
6158
"NEXT_PUBLIC_DATA_URL"
6259
]
6360
},
@@ -80,7 +77,6 @@
8077
"NEXT_PUBLIC_BASE_PATH",
8178
"NEXT_PUBLIC_ORAMA_API_KEY",
8279
"NEXT_PUBLIC_ORAMA_ENDPOINT",
83-
"NEXT_PUBLIC_VERCEL_REVALIDATE_TIME",
8480
"NEXT_PUBLIC_DATA_URL"
8581
]
8682
},

packages/i18n/lib/index.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
import localeConfig from '@node-core/website-i18n/config.json' assert { type: 'json' };
3+
import localeConfig from '@node-core/website-i18n/config.json' with { type: 'json' };
44

55
/**
66
* Imports a locale when exists from the locales directory

0 commit comments

Comments
 (0)