-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy path[slug].js
52 lines (48 loc) · 1.14 KB
/
[slug].js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
const Product = ({ time, slug }) => (
<div>
<h1>Product {slug}</h1>
<p>
This page uses getStaticProps() and getStaticPaths() to pre-fetch a Product
<span data-testid="date-now">{time}</span>
</p>
</div>
)
/** @type {import('next').GetStaticProps} */
export async function getStaticProps({ params }) {
if (params.slug === 'not-found-no-revalidate') {
return {
notFound: true,
}
} else if (params.slug === 'not-found-with-revalidate') {
return {
notFound: true,
revalidate: 600,
}
}
return {
props: {
time: new Date().toISOString(),
slug: params.slug,
},
}
}
/** @type {import('next').GetStaticPaths} */
export const getStaticPaths = ({ locales }) => {
return {
paths: [
{
params: {
slug: 'prerendered',
},
},
{
params: {
// Japanese prerendered (non-ascii) and comma
slug: '事前レンダリング,test',
},
},
].flatMap((pathDescription) => locales.map((locale) => ({ ...pathDescription, locale }))),
fallback: 'blocking', // false or "blocking"
}
}
export default Product