-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into with-mdx-remote-example
- Loading branch information
Showing
46 changed files
with
435 additions
and
431 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": ["next/babel"], | ||
"plugins": [ | ||
["babel-plugin-react-intl", { | ||
"ast": true, | ||
"idInterpolationPattern": "[sha512:contenthash:base64:6]", | ||
"extractFromFormatMessageCall": true | ||
}] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,3 +33,4 @@ yarn-error.log* | |
|
||
# vercel | ||
.vercel | ||
compiled-lang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"editor.formatOnSave": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as React from 'react'; | ||
import {useIntl} from 'react-intl'; | ||
import Head from 'next/head'; | ||
import Nav from './Nav'; | ||
|
||
export default function Layout({title, children}) { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<div> | ||
<Head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<title> | ||
{title || | ||
intl.formatMessage({ | ||
defaultMessage: 'React Intl Next.js Example', | ||
})} | ||
</title> | ||
</Head> | ||
|
||
<header> | ||
<Nav /> | ||
</header> | ||
|
||
{children} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"title": "React Intl Next.js Example", | ||
"nav.home": "Home", | ||
"nav.about": "About", | ||
"description": "An example app integrating React Intl with Next.js", | ||
"greeting": "Hello, World!" | ||
"11754": "An example app integrating React Intl with Next.js", | ||
"65a8e": "Hello, World!", | ||
"8cf04": "Home", | ||
"8f7f4": "About", | ||
"9c817": "React Intl Next.js Example" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"title": "React Intl Next.js Exemple", | ||
"nav.home": "Accueil", | ||
"nav.about": "À propos de nous", | ||
"description": "Un exemple d'application intégrant React Intl avec Next.js", | ||
"greeting": "Bonjour le monde!" | ||
"11754": "Un exemple d'application intégrant React Intl avec Next.js", | ||
"65a8e": "Bonjour le monde!", | ||
"8cf04": "Accueil", | ||
"8f7f4": "À propos de nous", | ||
"9c817": "React Intl Next.js Exemple" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/// <reference types="next" /> | ||
/// <reference types="next/types/global" /> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as React from 'react'; | ||
import {IntlProvider} from 'react-intl'; | ||
import {polyfill} from '../polyfills'; | ||
import App from 'next/app'; | ||
|
||
function MyApp({Component, pageProps, locale, messages}) { | ||
return ( | ||
<IntlProvider locale={locale} messages={messages}> | ||
<Component {...pageProps} /> | ||
</IntlProvider> | ||
); | ||
} | ||
|
||
// We need to load and expose the translations on the request for the user's | ||
// locale. These will only be used in production, in dev the `defaultMessage` in | ||
// each message description in the source code will be used. | ||
const getMessages = (locale: string = 'en') => { | ||
switch (locale) { | ||
default: | ||
return import('../compiled-lang/en.json'); | ||
case 'fr': | ||
return import('../compiled-lang/fr.json'); | ||
} | ||
}; | ||
|
||
const getInitialProps: typeof App.getInitialProps = async appContext => { | ||
const { | ||
ctx: {req}, | ||
} = appContext; | ||
const locale = (req as any)?.locale ?? 'en'; | ||
|
||
const [appProps, messages] = await Promise.all([ | ||
polyfill(locale), | ||
getMessages(locale), | ||
App.getInitialProps(appContext), | ||
]); | ||
|
||
return {...(appProps as any), locale, messages}; | ||
}; | ||
|
||
MyApp.getInitialProps = getInitialProps; | ||
|
||
export default MyApp; |
Oops, something went wrong.