-
Notifications
You must be signed in to change notification settings - Fork 26.1k
/
[slug].js
69 lines (59 loc) · 1.41 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { useRouter } from 'next/router'
import Link from 'next/link'
export const getStaticProps = ({ params }) => {
return {
props: {
params: params || null,
preview: true,
},
}
}
export const getStaticPaths = () => {
return {
paths: [],
fallback: 'blocking',
}
}
export default function Page(props) {
const router = useRouter()
return (
<>
<p id="preview">preview page</p>
<p id="pathname">{router.pathname}</p>
<p id="query">{JSON.stringify(router.query)}</p>
<p id="props">{JSON.stringify(props)}</p>
<Link href="/?imageId=123" as="/preview/123" id="to-modal">
open modal for /preview/123
</Link>
<br />
<Link href="/preview/321" id="to-preview">
go to /preview/321
</Link>
<br />
<Link href="/another" id="to-another">
go to /another
</Link>
<br />
<Link href="/rewrite-me" id="to-rewrite-me">
go to /rewrite-me
</Link>
<br />
<Link
href={{ pathname: '/preview/[slug]', query: { slug: '321' } }}
as="/rewrite-me"
id="to-preview-as-rewrite"
>
go to /preview/321 as /rewrite-me
</Link>
<br />
<Link
href={{ pathname: '/news/[[...slugs]]', query: { slugs: [] } }}
as="/blog"
id="to-news-as-blog"
>
go to /news as /blog
</Link>
<br />
</>
)
}