1
1
import Head from "next/head" ;
2
- import { prefix } from "../constants " ;
2
+ import RepoCard from "../components/Projcts/ RepoCard " ;
3
3
4
- export default function Projects ( { projectsData } ) {
4
+ export const getStaticProps = async ( ) => {
5
+ try {
6
+ const res = await fetch ( 'https://api.github.com/users/WebXDAO/repos' ) ;
7
+ const data = await res . json ( )
8
+
9
+ if ( ! data ) {
10
+ return {
11
+ props : {
12
+ success : false ,
13
+ message : "No data found"
14
+ }
15
+ } ;
16
+ }
17
+ return {
18
+ props : {
19
+ success : true ,
20
+ projectsData : data
21
+ }
22
+ } ;
23
+ } catch ( e ) {
24
+ return {
25
+ props : {
26
+ success : false ,
27
+ message : e
28
+ }
29
+ } ;
30
+ }
31
+ }
32
+
33
+ const Projects = ( { success = false , projectsData = [ ] } ) => {
5
34
return (
6
35
< >
7
36
< Head >
@@ -20,85 +49,22 @@ export default function Projects({ projectsData }) {
20
49
</ section >
21
50
22
51
< div className = "container max-w-screen-xl mx-auto my-8 grid pb-8 grid-cols-1 md:grid-cols-2 lg:grid-cols-3 mb-0 sm:mb-8 gap-6 px-8" >
23
- { projectsData . map (
24
- ( { name, imgUrl, type, title, text, tags } , index ) => (
52
+ { success ? projectsData . length > 0 && projectsData . map ( ( repo , index ) => (
25
53
< div
26
- key = { name + index }
54
+ key = { index }
27
55
className = "flex flex-col justify-between items-stretch col-span-3 md:col-span-1 cursor-pointer p-2 shadow rounded-md focus:outline-none focus:shadow-outline transform transition hover:shadow-lg hover:scale-105 duration-300 ease-in-out"
28
56
>
29
- < div className = "bg-white p-4 rounded-lg flex flex-col justify-between" >
30
- < div className = "relative mb-6" >
31
- < img
32
- className = "h-44 md:h-64 lg:h-60 xl:h-56 w-full object-cover object-center rounded-md"
33
- src = { prefix + imgUrl }
34
- alt = { name }
35
- />
36
- </ div >
37
- < div className = "flex justify-between items-center md:items-start mb-2 md:mb-4" >
38
- < h2 className = "text-lg md:text-xl text-gray-900 font-semibold" >
39
- { title }
40
- </ h2 >
41
- < h3
42
- className = { `tracking-widest ${ type === 'FREE' ? 'text-green-500' : 'text-yellow-500'
43
- } text-sm font-semibold title-font`}
44
- >
45
- { type }
46
- </ h3 >
47
- </ div >
48
-
49
- < p className = "leading-relaxed text-sm md:text-base text-gray-800 mb-5" >
50
- { text }
51
- </ p >
52
-
53
- < div className = "mt-auto justify-items-end text-sm flex flex-wrap gap-3" >
54
- { tags . map ( ( item , index ) => (
55
- < button
56
- key = { item + index }
57
- className = "whitespace-nowrap font-semibold bg-blue-100 text-blue-600 rounded-md py-2 px-4 focus:outline-none"
58
- >
59
- { item }
60
- </ button >
61
- ) ) }
62
- </ div >
63
- </ div >
57
+ < RepoCard repo = { repo } />
64
58
</ div >
65
- )
66
- ) }
59
+ )
60
+ ) : (
61
+ < div >
62
+ Error fetching data! Please try again later.
63
+ </ div >
64
+ ) }
67
65
</ div >
68
66
</ >
69
67
) ;
70
68
}
71
69
72
- export function getStaticProps ( ) {
73
- const data = [
74
- {
75
- name : "InVision" ,
76
- imgUrl : "/blogs_inVision.png" ,
77
- type : "PREMIUM" ,
78
- title : "Start Here" ,
79
- text : "InVision is the digital product design platform used to make the worlds best customer experiences." ,
80
- tags : [ "Documentation" ] ,
81
- } ,
82
- {
83
- name : "Adobe XD" ,
84
- imgUrl : "/blogs_xd.png" ,
85
- type : "FREE" ,
86
- title : "Blockchain Dev Path" ,
87
- text : "Adobe XD is your UI/UX design solution platform for website and mobile appcreation." ,
88
- tags : [ "Documentation" ] ,
89
- } ,
90
- {
91
- name : "Figma" ,
92
- imgUrl : "/blogs_figma.png" ,
93
- type : "FREE" ,
94
- title : "Website" ,
95
- text : "Figma helps the teams to create, test, and ship better designs from start to finish." ,
96
- tags : [ "Tailwind Css" , "Eleventy" , "Alpine.js" ] ,
97
- } ,
98
- ] ;
99
- return {
100
- props : {
101
- projectsData : data ,
102
- } ,
103
- } ;
104
- }
70
+ export default Projects ;
0 commit comments