-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy path[slug].js
51 lines (47 loc) · 1.17 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
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>
)
export async function getStaticProps({ params }) {
if (params.slug === 'not-found-with-revalidate') {
return {
notFound: true,
revalidate: 600,
}
}
return {
props: {
time: new Date().toISOString(),
slug: params.slug,
},
}
}
export const getStaticPaths = () => {
return {
paths: [
{
params: {
slug: 'an-incredibly-long-product-name-thats-impressively-repetetively-needlessly-overdimensioned-and-should-be-shortened-to-less-than-255-characters-for-the-sake-of-seo-and-ux-and-first-and-foremost-for-gods-sake-but-nobody-wont-ever-read-this-anyway',
},
},
{
params: {
slug: 'prerendered',
},
},
{
params: {
// Japanese prerendered (non-ascii) and comma
slug: '事前レンダリング,test',
},
},
],
fallback: 'blocking', // false or "blocking"
}
}
export default Product