-
Notifications
You must be signed in to change notification settings - Fork 6.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
meta: adopt next-intl and app router #6092
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
a094737
to
5ca739a
Compare
Lighthouse Results
|
Hey y'all, as I believe that a full review of this PR is pretty hard, and to unblock further development. I'm queueing this to our merge queue. Please feel free to do any sort of reviews post-merge. I've battle-tested this and so far all good, so let's do it. |
e1bb198
to
a6671e9
Compare
code: kept working on adoption of i18n feat: app router transition meta: renamed sections to containers due to fs casing fix: force static fix: minor fixes of build and caching feat: metadata of each page fix: tests and stuff fix: tiny type fix chore: updated link to guide chore: intl on stories chore: no usage of assert refactor: some more cleanups on codebase meta: some improvements and fixes refactor: more code review changes refactor: more standardisation next-intl chore: minor changes to 404 refactor: code cleanup and reusability fix: fixed tests and imports chore: minor fixes and test updates fix: sitemap generation and 404 ignore chore: cleanup activelocalizedlink chore: remove legacy sto-top chore: more cleanups chore: more cleanups chore: use right import chore: optimise generation of blog meta chore: small cleanup chore: updated collaborator guide meta: provide server and client version of hooks fix: tests imports fix: styles of blogcard
a6671e9
to
61837dd
Compare
cc @nodejs/web-infra regarding my message above ☝️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have only minor review notes ✨ In addition to these changes, it would be good to update the part of the collaborator guide that points to the location of the layouts (https://github.com/nodejs/nodejs.org/blob/main/COLLABORATOR_GUIDE.md?plain=1#L143-L145)
export const generateMetadata = async (c: DynamicParams) => { | ||
const { path = [], locale = defaultLocale.code } = c.params; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const generateMetadata = async (c: DynamicParams) => { | |
const { path = [], locale = defaultLocale.code } = c.params; | |
export const generateMetadata = async ({params} : DynamicParams) => { | |
const { path = [], locale = defaultLocale.code } = params; |
c
doesn't mean much, we can deconstruct directly
for (const locale of availableLocaleCodes) { | ||
const routesForLanguage = await dynamicRouter.getRoutesByLanguage(locale); | ||
|
||
paths.push(...routesForLanguage.map(route => `${locale}/${route}`)); | ||
} | ||
|
||
// The current date of this request | ||
const currentDate = new Date().toISOString(); | ||
|
||
const appRoutes = [...dynamicRoutes, ...staticPaths] | ||
.sort() | ||
.map(route => `${baseUrlAndPath}/${route}`); | ||
const appRoutes = paths.sort().map(route => `${baseUrlAndPath}/${route}`); | ||
|
||
return [...appRoutes, ...EXTERNAL_LINKS_SITEMAP].map(route => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const locale of availableLocaleCodes) { | |
const routesForLanguage = await dynamicRouter.getRoutesByLanguage(locale); | |
paths.push(...routesForLanguage.map(route => `${locale}/${route}`)); | |
} | |
// The current date of this request | |
const currentDate = new Date().toISOString(); | |
const appRoutes = [...dynamicRoutes, ...staticPaths] | |
.sort() | |
.map(route => `${baseUrlAndPath}/${route}`); | |
const appRoutes = paths.sort().map(route => `${baseUrlAndPath}/${route}`); | |
return [...appRoutes, ...EXTERNAL_LINKS_SITEMAP].map(route => ({ | |
for (const locale of availableLocaleCodes) { | |
const routesForLanguage = await dynamicRouter.getRoutesByLanguage(locale); | |
paths.push(...routesForLanguage.map(route => `${baseUrlAndPath}/${locale}/${route}`)); | |
} | |
const currentDate = new Date().toISOString(); | |
return [...paths, ...EXTERNAL_LINKS_SITEMAP].map(route => ({ |
We can directly pass baseUrlAndPath
no need to sort and map again
@@ -0,0 +1,24 @@ | |||
import { cache } from 'react'; | |||
|
|||
import type { ClientSharedServerContext } from './types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import type { ClientSharedServerContext } from './types'; | |
import type { ClientSharedServerContext } from '@/types'; |
@canerakdas can you open a new PR with these changes? (All of them) |
Description
This PR refactors the Node.js Website and adopts the new Next.js App Router. This PR does all the necessary changes to make the app router-compatible. Bear in mind that some changes here are temporary.
Note: This PR is still going to have some updates, such as improvement of documentation, updates on Collaborator Guides, etc.
Changes
react-intl
and our custom i18n middleware in favour ofnext-intl
next-intl
v3next-intl
usesnext-intl
and its componentsLocalizedLink
,useLocale
, etc in favor ofnext-intl
builtin'snext.dynamic.mjs
, our App Root Layout, and all the coreapp/
folders to make the whole process of building and rendering compatible.Caveat
This rework is stable, but
next-intl
3.0 is still on Release Candidate, and a few things might change. For example, the usage of an unstable API https://next-intl-docs-git-feat-next-13-rsc-next-intl.vercel.app/docs/getting-started/app-router#add-unstable_setrequestlocale-to-all-layouts-and-pagesValidation
Builds should pass, Linting should pass, Deployment should pass, all pages should work as expected.
Deep testing is needed here!