diff --git a/src/app/contributors/page.tsx b/src/app/contributors/page.tsx new file mode 100644 index 00000000..1553d9de --- /dev/null +++ b/src/app/contributors/page.tsx @@ -0,0 +1,76 @@ +'use client'; + +import Image from 'next/image'; +import Link from 'next/link'; +import { useState, useEffect } from 'react'; + +interface Contributor { + html_url: string; + avatar_url: string; + login: string; + contributions: number; +} + +const Contributors = () => { + const URL = 'https://api.github.com/repos/Avdhesh-Varshney/WebMasterLog/contributors?per_page=500'; + const [contributors, setContributors] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [hoveredContributor, setHoveredContributor] = useState(null); + + useEffect(() => { + fetch(URL, { + next: { + revalidate: 86400, + }, + }) + .then((res) => res.json()) + .then((data) => { + setContributors(data); + setLoading(false); + }) + .catch((error) => { + setError(error.message); + setLoading(false); + }); + }, []); + + if (loading) return
Loading...
; + if (error) return
Error: {error}
; + console.log(contributors[0]) + + return ( +
+

Our Valuable Contributors

+
+ {contributors.length > 0 ? ( + contributors.map((contributor, index) => ( +
setHoveredContributor(contributor)} + onMouseLeave={() => setHoveredContributor(null)} + > +
+ {contributor.login} +
+ {hoveredContributor === contributor && ( +
+ + {contributor.login} + +

{contributor.login}

+

Contributions: {contributor.contributions} 🏆

+
+ )} +
+ )) + ) : ( +

API Limit Exceeded!

+ )} +
+
+ ); +}; + +export default Contributors;