File tree Expand file tree Collapse file tree 3 files changed +23
-28
lines changed Expand file tree Collapse file tree 3 files changed +23
-28
lines changed Original file line number Diff line number Diff line change @@ -5,15 +5,7 @@ import Seo from "../components/Seo";
5
5
export default function Home ( { results } ) {
6
6
const router = useRouter ( ) ;
7
7
const onClick = ( id , title ) => {
8
- router . push (
9
- {
10
- pathname : `/movies/${ id } ` ,
11
- query : {
12
- title,
13
- } ,
14
- } ,
15
- `/movies/${ id } `
16
- ) ;
8
+ router . push ( `/movies/${ title } /${ id } ` ) ;
17
9
} ;
18
10
return (
19
11
< div className = "container" >
@@ -26,15 +18,7 @@ export default function Home({ results }) {
26
18
>
27
19
< img src = { `https://image.tmdb.org/t/p/w500${ movie . poster_path } ` } />
28
20
< h4 >
29
- < Link
30
- href = { {
31
- pathname : `/movies/${ movie . id } ` ,
32
- query : {
33
- title : movie . original_title ,
34
- } ,
35
- } }
36
- as = { `/movies/${ movie . id } ` }
37
- >
21
+ < Link href = { `/movies/${ movie . original_title } /${ movie . id } ` } >
38
22
< a > { movie . original_title } </ a >
39
23
</ Link >
40
24
</ h4 >
Original file line number Diff line number Diff line change
1
+ import Seo from "../../components/Seo" ;
2
+ import { useRouter } from "next/router" ;
3
+
4
+ export default function Detail ( { params } ) {
5
+ const router = useRouter ( ) ;
6
+ const [ title , id ] = params || [ ] ;
7
+ return (
8
+ < div >
9
+ < Seo title = { title } />
10
+ < h4 > { title } </ h4 >
11
+ </ div >
12
+ ) ;
13
+ }
14
+
15
+ export function getServerSideProps ( { params : { params } } ) {
16
+ return {
17
+ props : {
18
+ params,
19
+ } ,
20
+ } ;
21
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments