File tree Expand file tree Collapse file tree 3 files changed +46
-10
lines changed Expand file tree Collapse file tree 3 files changed +46
-10
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,4 @@ yarn-error.log*
32
32
33
33
# vercel
34
34
.vercel
35
+ .env
Original file line number Diff line number Diff line change
1
+ const API_KEY = process . env . API_KEY ;
2
+
1
3
module . exports = {
2
4
reactStrictMode : true ,
3
- }
5
+ async redirects ( ) {
6
+ return [
7
+ {
8
+ source : "/old-blog/:path*" ,
9
+ destination : "/new-sexy-blog/:path*" ,
10
+ permanent : false ,
11
+ } ,
12
+ ] ;
13
+ } ,
14
+ async rewrites ( ) {
15
+ return [
16
+ {
17
+ source : "/api/movies" ,
18
+ destination : `https://api.themoviedb.org/3/movie/popular?api_key=${ API_KEY } ` ,
19
+ } ,
20
+ ] ;
21
+ } ,
22
+ } ;
Original file line number Diff line number Diff line change 1
1
import { useEffect , useState } from "react" ;
2
2
import Seo from "../components/Seo" ;
3
3
4
- const API_KEY = "10923b261ba94d897ac6b81148314a3f" ;
5
-
6
4
export default function Home ( ) {
7
5
const [ movies , setMovies ] = useState ( ) ;
8
6
useEffect ( ( ) => {
9
7
( async ( ) => {
10
- const { results } = await (
11
- await fetch (
12
- `https://api.themoviedb.org/3/movie/popular?api_key=${ API_KEY } `
13
- )
14
- ) . json ( ) ;
8
+ const { results } = await ( await fetch ( `/api/movies` ) ) . json ( ) ;
15
9
setMovies ( results ) ;
16
10
} ) ( ) ;
17
11
} , [ ] ) ;
18
12
return (
19
- < div >
13
+ < div className = "container" >
20
14
< Seo title = "Home" />
21
15
{ ! movies && < h4 > Loading...</ h4 > }
22
16
{ movies ?. map ( ( movie ) => (
23
- < div key = { movie . id } >
17
+ < div className = "movie" key = { movie . id } >
18
+ < img src = { `https://image.tmdb.org/t/p/w500/${ movie . poster_path } ` } />
24
19
< h4 > { movie . original_title } </ h4 >
25
20
</ div >
26
21
) ) }
22
+ < style jsx > { `
23
+ .container {
24
+ display: grid;
25
+ grid-template-columns: 1fr 1fr;
26
+ padding: 20px;
27
+ gap: 20px;
28
+ }
29
+ .movie img {
30
+ max-width: 100%;
31
+ border-radius: 12px;
32
+ transition: transform 0.2s ease-in-out;
33
+ box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
34
+ }
35
+ .movie:hover img {
36
+ transform: scale(1.05) translateY(-10px);
37
+ }
38
+ .movie h4 {
39
+ font-size: 18px;
40
+ text-align: center;
41
+ }
42
+ ` } </ style >
27
43
</ div >
28
44
) ;
29
45
}
You can’t perform that action at this time.
0 commit comments