File tree Expand file tree Collapse file tree 6 files changed +182
-3
lines changed Expand file tree Collapse file tree 6 files changed +182
-3
lines changed Original file line number Diff line number Diff line change 1+ module . exports = {
2+ experimental : {
3+ i18n : {
4+ locales : [ 'en' , 'fr' , 'nl' ] ,
5+ defaultLocale : 'en' ,
6+ } ,
7+ } ,
8+ }
Original file line number Diff line number Diff line change 1+ import Link from 'next/link'
2+ import { useRouter } from 'next/router'
3+
4+ export default function GspPage ( props ) {
5+ const router = useRouter ( )
6+ const { defaultLocale, isFallback, query } = router
7+
8+ if ( isFallback ) {
9+ return 'Loading...'
10+ }
11+
12+ return (
13+ < div >
14+ < h1 > getServerSideProps page</ h1 >
15+ < p > Current slug: { query . slug } </ p >
16+ < p > Current locale: { props . locale } </ p >
17+ < p > Default locale: { defaultLocale } </ p >
18+ < p > Configured locales: { JSON . stringify ( props . locales ) } </ p >
19+
20+ < Link href = "/gsp" >
21+ < a > To getStaticProps page</ a >
22+ </ Link >
23+ < br />
24+
25+ < Link href = "/gssp" >
26+ < a > To getServerSideProps page</ a >
27+ </ Link >
28+ < br />
29+
30+ < Link href = "/" >
31+ < a > To index page</ a >
32+ </ Link >
33+ < br />
34+ </ div >
35+ )
36+ }
37+
38+ export const getStaticProps = ( { locale, locales } ) => {
39+ return {
40+ props : {
41+ locale,
42+ locales,
43+ } ,
44+ }
45+ }
46+
47+ export const getStaticPaths = ( { locales } ) => {
48+ const paths = [ ]
49+
50+ for ( const locale of locales ) {
51+ paths . push ( { params : { slug : 'first' } , locale } )
52+ paths . push ( { params : { slug : 'second' } , locale } )
53+ }
54+
55+ return {
56+ paths,
57+ fallback : true ,
58+ }
59+ }
Original file line number Diff line number Diff line change 1+ import Link from 'next/link'
2+ import { useRouter } from 'next/router'
3+
4+ export default function GspPage ( props ) {
5+ const router = useRouter ( )
6+ const { defaultLocale } = router
7+
8+ return (
9+ < div >
10+ < h1 > getServerSideProps page</ h1 >
11+ < p > Current locale: { props . locale } </ p >
12+ < p > Default locale: { defaultLocale } </ p >
13+ < p > Configured locales: { JSON . stringify ( props . locales ) } </ p >
14+
15+ < Link href = "/gsp/first" >
16+ < a > To dynamic getStaticProps page</ a >
17+ </ Link >
18+ < br />
19+
20+ < Link href = "/gssp" >
21+ < a > To getServerSideProps page</ a >
22+ </ Link >
23+ < br />
24+
25+ < Link href = "/" >
26+ < a > To index page</ a >
27+ </ Link >
28+ < br />
29+ </ div >
30+ )
31+ }
32+
33+ export const getStaticProps = ( { locale, locales } ) => {
34+ return {
35+ props : {
36+ locale,
37+ locales,
38+ } ,
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ import Link from 'next/link'
2+ import { useRouter } from 'next/router'
3+
4+ export default function GsspPage ( props ) {
5+ const router = useRouter ( )
6+ const { defaultLocale } = router
7+
8+ return (
9+ < div >
10+ < h1 > getServerSideProps page</ h1 >
11+ < p > Current locale: { props . locale } </ p >
12+ < p > Default locale: { defaultLocale } </ p >
13+ < p > Configured locales: { JSON . stringify ( props . locales ) } </ p >
14+
15+ < Link href = "/gsp" >
16+ < a > To getStaticProps page</ a >
17+ </ Link >
18+ < br />
19+
20+ < Link href = "/gsp/first" >
21+ < a > To dynamic getStaticProps page</ a >
22+ </ Link >
23+ < br />
24+
25+ < Link href = "/" >
26+ < a > To index page</ a >
27+ </ Link >
28+ < br />
29+ </ div >
30+ )
31+ }
32+
33+ export const getServerSideProps = ( { locale, locales } ) => {
34+ return {
35+ props : {
36+ locale,
37+ locales,
38+ } ,
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ import Link from 'next/link'
2+ import { useRouter } from 'next/router'
3+
4+ export default function IndexPage ( props ) {
5+ const router = useRouter ( )
6+ const { locale, locales, defaultLocale } = router
7+
8+ return (
9+ < div >
10+ < h1 > Index page</ h1 >
11+ < p > Current locale: { locale } </ p >
12+ < p > Default locale: { defaultLocale } </ p >
13+ < p > Configured locales: { JSON . stringify ( locales ) } </ p >
14+
15+ < Link href = "/gsp" >
16+ < a > To getStaticProps page</ a >
17+ </ Link >
18+ < br />
19+
20+ < Link href = "/gsp/first" >
21+ < a > To dynamic getStaticProps page</ a >
22+ </ Link >
23+ < br />
24+
25+ < Link href = "/gssp" >
26+ < a > To getServerSideProps page</ a >
27+ </ Link >
28+ < br />
29+ </ div >
30+ )
31+ }
Original file line number Diff line number Diff line change @@ -15826,9 +15826,10 @@ styled-jsx-plugin-postcss@2.0.1:
1582615826 postcss "^7.0.2"
1582715827 postcss-load-plugins "^2.3.0"
1582815828
15829- styled-jsx@3.3.0:
15830- version "3.3.0"
15831- resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-3.3.0.tgz#32335c1a3ecfc923ba4f9c056eeb3d4699006b09"
15829+ styled-jsx@3.3.1:
15830+ version "3.3.1"
15831+ resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-3.3.1.tgz#d79f306c42c99cefbe8e76f35dad8100dc5c9ecc"
15832+ integrity sha512-RhW71t3k95E3g7Zq3lEBk+kmf+p4ZME7c5tfsYf9M5mq6CgIvFXkbvhawL2gWriXLRlMyKAYACE89Qa2JnTqUw==
1583215833 dependencies:
1583315834 "@babel/types" "7.8.3"
1583415835 babel-plugin-syntax-jsx "6.18.0"
You can’t perform that action at this time.
0 commit comments