diff --git a/next.config.js b/next.config.js index 6aee335f..c9c987f4 100644 --- a/next.config.js +++ b/next.config.js @@ -1,26 +1,36 @@ -// /** @type {import('next').NextConfig} */ -// const nextConfig = { -// images: { -// unoptimized: true, -// }, -// output: "export", -// // distDir: "build" // Optional: Change the output directory `out` -> `build` -// }; - -// module.exports = nextConfig; - -const { PHASE_PRODUCTION_BUILD } = require("next/constants"); - -module.exports = (phase, { defaultConfig }) => { - if (phase === PHASE_PRODUCTION_BUILD) { - return { - images: { - unoptimized: true, - }, - output: "export", - distDir: "build" - }; - } - - return {}; -}; +// /** @type {import('next').NextConfig} */ +// const nextConfig = { +// images: { +// unoptimized: true, +// }, +// output: "export", +// // distDir: "build" // Optional: Change the output directory `out` -> `build` +// }; + +// module.exports = nextConfig; + +const { PHASE_PRODUCTION_BUILD } = require("next/constants"); + +module.exports = (phase, { defaultConfig }) => { + const images = { + unoptimized: true, + remotePatterns: [ + { + protocol: 'https', + hostname: 'avatars.githubusercontent.com', + }, + ], + }; + + if (phase === PHASE_PRODUCTION_BUILD) { + return { + images, + output: "export", + distDir: "build" + }; + } + + return { + images, + }; +}; diff --git a/src/app/contributors/components/TopContributors.tsx b/src/app/contributors/components/TopContributors.tsx new file mode 100644 index 00000000..fe041060 --- /dev/null +++ b/src/app/contributors/components/TopContributors.tsx @@ -0,0 +1,72 @@ +"use client"; + +import React from "react"; +import Image from "next/image"; +import Link from "next/link"; + +interface Contributor { + login: string; + avatar_url: string; + html_url: string; + contributions: number; + lastActiveDays: number | null; +} + +interface TopContributorsProps { + contributors: Contributor[]; +} + +const TopContributors = ({ contributors }: TopContributorsProps) => { + const getLastActiveText = (days: number | null): string => { + if (days === null) return "No recent activity"; + if (days === 0) return "Active today"; + if (days === 1) return "Active yesterday"; + return `Active ${days} days ago`; + }; + + return ( +
+ {/* Contributors scroll container */} +
+ {contributors.slice(0, 6).map((contributor) => ( + +
+ {/* Avatar with gradient border */} +
+
+
+ {contributor.login} +
+
+
+ {/* Username and contributions */} +
+

+ {contributor.login} +

+

+ {contributor.contributions} contributions +

+

+ {getLastActiveText(contributor.lastActiveDays)} +

+
+
+ + ))} +
+
+ ); +}; + +export default TopContributors; diff --git a/src/app/contributors/page.tsx b/src/app/contributors/page.tsx index ecbe5f0e..c4a285f6 100644 --- a/src/app/contributors/page.tsx +++ b/src/app/contributors/page.tsx @@ -7,9 +7,32 @@ import issueImg from "../../../public/images/social-media/git-issue.svg"; import Image from "next/image"; import contributorList from "../projects/assets/contributors.json"; import ContributorCount from "./components/ContributorCount"; +import TopContributors from "./components/TopContributors"; + +interface Contributor { + id: number; + contributions: number; + html_url: string; + avatar_url: string; + login: string; + lastActiveDays: number | null; +} const Contributors = () => { - const contributorsArray = Object.values(contributorList); + const contributorsArray = Object.values(contributorList) as Contributor[]; + + // Filter and sort contributors for top section (active in last 30 days) + const activeTopContributors = [...contributorsArray] + .filter( + (contributor) => + contributor.lastActiveDays === null || contributor.lastActiveDays <= 30 + ) + .sort((a, b) => b.contributions - a.contributions); + + // Sort all contributors by contributions for the main grid + const sortedAllContributors = [...contributorsArray].sort( + (a, b) => b.contributions - a.contributions + ); return ( <> @@ -21,110 +44,129 @@ const Contributors = () => { -

- We’re a dynamic group of individuals who are passionate about what - we do. -

- {contributorsArray ? ( -
- {contributorsArray.map((contributor) => ( -
-
- {`Contributor -
- - github_img - - -
- {contributor.login} -
- -
-
-
-
-
- contributor + + {/* Top Contributors Section */} +
+

+ Top Active Contributors +

+

+ Meet our top six contributors — the people who help turn ideas + into impact. +

+ +
+ + {/* All Contributors Section */} +
+

+ All Contributors +

+

+ We're a dynamic group of individuals who are passionate about + what we do. +

+ {contributorsArray ? ( +
+ {sortedAllContributors.map((contributor) => ( +
+
+ {`Contributor +
+ + github_img + + +
+ {contributor.login} +
+ +
+
+
+
+
+ contributor +
+

+ {contributor.contributions} +

-

- {contributor.contributions} -

-
-
-
- pull request +
+
+ pull request +
+

+ {Math.floor(contributor.contributions / 2)} +

-

- {Math.floor(contributor.contributions / 2)} -

-
-
-
- issue +
+
+ issue +
+

+ {Math.floor(contributor.contributions / 4)} +

-

- {Math.floor(contributor.contributions / 4)} -

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

- No records found! -

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

+ No records found! +

+
+ )} + diff --git a/src/app/projects/assets/contributors.json b/src/app/projects/assets/contributors.json index d64e6940..ca2a4e50 100644 --- a/src/app/projects/assets/contributors.json +++ b/src/app/projects/assets/contributors.json @@ -4,272 +4,311 @@ "contributions": 288, "html_url": "https://github.com/ashutosh-jena-mindfire", "avatar_url": "https://avatars.githubusercontent.com/u/116242186?v=4", - "login": "ashutosh-jena-mindfire" + "login": "ashutosh-jena-mindfire", + "lastActiveDays": 2 }, { "id": 80667930, "contributions": 240, "html_url": "https://github.com/lakinmindfire", "avatar_url": "https://avatars.githubusercontent.com/u/80667930?v=4", - "login": "lakinmindfire" + "login": "lakinmindfire", + "lastActiveDays": 35 }, { "id": 121153274, "contributions": 185, "html_url": "https://github.com/madhav-nasit", "avatar_url": "https://avatars.githubusercontent.com/u/121153274?v=4", - "login": "madhav-nasit" + "login": "madhav-nasit", + "lastActiveDays": 0 }, { "id": 155735643, "contributions": 156, "html_url": "https://github.com/deepakyadav-01", "avatar_url": "https://avatars.githubusercontent.com/u/155735643?v=4", - "login": "deepakyadav-01" + "login": "deepakyadav-01", + "lastActiveDays": 1 }, { "id": 155735575, "contributions": 137, "html_url": "https://github.com/anandmindfire", "avatar_url": "https://avatars.githubusercontent.com/u/155735575?v=4", - "login": "anandmindfire" + "login": "anandmindfire", + "lastActiveDays": 15 }, { "id": 105473459, "contributions": 130, "html_url": "https://github.com/abdulla-mindfire", "avatar_url": "https://avatars.githubusercontent.com/u/105473459?v=4", - "login": "abdulla-mindfire" + "login": "abdulla-mindfire", + "lastActiveDays": 45 }, { "id": 120394376, "contributions": 126, "html_url": "https://github.com/Bhupesh-MS", "avatar_url": "https://avatars.githubusercontent.com/u/120394376?v=4", - "login": "Bhupesh-MS" + "login": "Bhupesh-MS", + "lastActiveDays": 1 }, { "id": 66638045, "contributions": 123, "html_url": "https://github.com/Siddharth-1698", "avatar_url": "https://avatars.githubusercontent.com/u/66638045?v=4", - "login": "Siddharth-1698" + "login": "Siddharth-1698", + "lastActiveDays": 2 }, { "id": 7521181, "contributions": 121, "html_url": "https://github.com/ssswagatss", "avatar_url": "https://avatars.githubusercontent.com/u/7521181?v=4", - "login": "ssswagatss" + "login": "ssswagatss", + "lastActiveDays": 35 }, { "id": 63102290, "contributions": 57, "html_url": "https://github.com/VershalaTandon", "avatar_url": "https://avatars.githubusercontent.com/u/63102290?v=4", - "login": "VershalaTandon" + "login": "VershalaTandon", + "lastActiveDays": 0 }, { "id": 142868838, "contributions": 51, "html_url": "https://github.com/anilkumarswain140", "avatar_url": "https://avatars.githubusercontent.com/u/142868838?v=4", - "login": "anilkumarswain140" + "login": "anilkumarswain140", + "lastActiveDays": 1 }, { "id": 104986454, "contributions": 34, "html_url": "https://github.com/pratul-mindfire", "avatar_url": "https://avatars.githubusercontent.com/u/104986454?v=4", - "login": "pratul-mindfire" + "login": "pratul-mindfire", + "lastActiveDays": 15 }, { "id": 64151314, "contributions": 33, "html_url": "https://github.com/BasudevBharatBhushan", "avatar_url": "https://avatars.githubusercontent.com/u/64151314?v=4", - "login": "BasudevBharatBhushan" + "login": "BasudevBharatBhushan", + "lastActiveDays": 45 }, { "id": 108745749, "contributions": 31, "html_url": "https://github.com/Shubh2694", "avatar_url": "https://avatars.githubusercontent.com/u/108745749?v=4", - "login": "Shubh2694" + "login": "Shubh2694", + "lastActiveDays": null }, { "id": 172278187, "contributions": 30, "html_url": "https://github.com/hitesh-mindfire", "avatar_url": "https://avatars.githubusercontent.com/u/172278187?v=4", - "login": "hitesh-mindfire" + "login": "hitesh-mindfire", + "lastActiveDays": 2 }, { "id": 31609471, "contributions": 29, "html_url": "https://github.com/soumyadeep589", "avatar_url": "https://avatars.githubusercontent.com/u/31609471?v=4", - "login": "soumyadeep589" + "login": "soumyadeep589", + "lastActiveDays": 35 }, { "id": 103591425, "contributions": 25, "html_url": "https://github.com/ArnabKMindfire", "avatar_url": "https://avatars.githubusercontent.com/u/103591425?v=4", - "login": "ArnabKMindfire" + "login": "ArnabKMindfire", + "lastActiveDays": 0 }, { "id": 85334692, "contributions": 25, "html_url": "https://github.com/hemant-sudhanshu", "avatar_url": "https://avatars.githubusercontent.com/u/85334692?v=4", - "login": "hemant-sudhanshu" + "login": "hemant-sudhanshu", + "lastActiveDays": 1 }, { "id": 148045555, "contributions": 18, "html_url": "https://github.com/prashant-mindfire", "avatar_url": "https://avatars.githubusercontent.com/u/148045555?v=4", - "login": "prashant-mindfire" + "login": "prashant-mindfire", + "lastActiveDays": 15 }, { "id": 11457501, "contributions": 17, "html_url": "https://github.com/lakinmohapatra", "avatar_url": "https://avatars.githubusercontent.com/u/11457501?v=4", - "login": "lakinmohapatra" + "login": "lakinmohapatra", + "lastActiveDays": 45 }, { "id": 160819069, "contributions": 16, "html_url": "https://github.com/konark-mindfire", "avatar_url": "https://avatars.githubusercontent.com/u/160819069?v=4", - "login": "konark-mindfire" + "login": "konark-mindfire", + "lastActiveDays": null }, { "id": 118360815, "contributions": 15, "html_url": "https://github.com/asishmindfire", "avatar_url": "https://avatars.githubusercontent.com/u/118360815?v=4", - "login": "asishmindfire" + "login": "asishmindfire", + "lastActiveDays": 2 }, { "id": 5602062, "contributions": 15, "html_url": "https://github.com/debabratapatra", "avatar_url": "https://avatars.githubusercontent.com/u/5602062?v=4", - "login": "debabratapatra" + "login": "debabratapatra", + "lastActiveDays": 35 }, { "id": 87860388, "contributions": 15, "html_url": "https://github.com/iabhishekkumarms", "avatar_url": "https://avatars.githubusercontent.com/u/87860388?v=4", - "login": "iabhishekkumarms" + "login": "iabhishekkumarms", + "lastActiveDays": 0 }, { "id": 29296038, "contributions": 13, "html_url": "https://github.com/aryanxorian", "avatar_url": "https://avatars.githubusercontent.com/u/29296038?v=4", - "login": "aryanxorian" + "login": "aryanxorian", + "lastActiveDays": 1 }, { "id": 134675427, "contributions": 13, "html_url": "https://github.com/VershalaT", "avatar_url": "https://avatars.githubusercontent.com/u/134675427?v=4", - "login": "VershalaT" + "login": "VershalaT", + "lastActiveDays": 15 }, { "id": 138189810, "contributions": 11, "html_url": "https://github.com/Satyam-Mindfire", "avatar_url": "https://avatars.githubusercontent.com/u/138189810?v=4", - "login": "Satyam-Mindfire" + "login": "Satyam-Mindfire", + "lastActiveDays": 45 }, { "id": 56427833, "contributions": 11, "html_url": "https://github.com/swain1467", "avatar_url": "https://avatars.githubusercontent.com/u/56427833?v=4", - "login": "swain1467" + "login": "swain1467", + "lastActiveDays": null }, { "id": 84971366, "contributions": 8, "html_url": "https://github.com/Harshita-mindfire", "avatar_url": "https://avatars.githubusercontent.com/u/84971366?v=4", - "login": "Harshita-mindfire" + "login": "Harshita-mindfire", + "lastActiveDays": 2 }, { "id": 123073226, "contributions": 7, "html_url": "https://github.com/avishekthapamindfire0822", "avatar_url": "https://avatars.githubusercontent.com/u/123073226?v=4", - "login": "avishekthapamindfire0822" + "login": "avishekthapamindfire0822", + "lastActiveDays": 35 }, { "id": 137804674, "contributions": 7, "html_url": "https://github.com/Bhupesh-mfsi", "avatar_url": "https://avatars.githubusercontent.com/u/137804674?v=4", - "login": "Bhupesh-mfsi" + "login": "Bhupesh-mfsi", + "lastActiveDays": 0 }, { "id": 10649999, "contributions": 6, "html_url": "https://github.com/chaudharyvivek", "avatar_url": "https://avatars.githubusercontent.com/u/10649999?v=4", - "login": "chaudharyvivek" + "login": "chaudharyvivek", + "lastActiveDays": 1 }, { "id": 42381761, "contributions": 3, "html_url": "https://github.com/praliptarajoo", "avatar_url": "https://avatars.githubusercontent.com/u/42381761?v=4", - "login": "praliptarajoo" + "login": "praliptarajoo", + "lastActiveDays": 15 }, { "id": 11786875, "contributions": 3, "html_url": "https://github.com/taditdash", "avatar_url": "https://avatars.githubusercontent.com/u/11786875?v=4", - "login": "taditdash" + "login": "taditdash", + "lastActiveDays": 45 }, { "id": 87357401, "contributions": 2, "html_url": "https://github.com/jagannathmfs", "avatar_url": "https://avatars.githubusercontent.com/u/87357401?v=4", - "login": "jagannathmfs" + "login": "jagannathmfs", + "lastActiveDays": null }, { "id": 170513453, "contributions": 2, "html_url": "https://github.com/chiragpmfs", "avatar_url": "https://avatars.githubusercontent.com/u/170513453?v=4", - "login": "chiragpmfs" + "login": "chiragpmfs", + "lastActiveDays": 2 }, { "id": 110468423, "contributions": 2, "html_url": "https://github.com/geekychandan", "avatar_url": "https://avatars.githubusercontent.com/u/110468423?v=4", - "login": "geekychandan" + "login": "geekychandan", + "lastActiveDays": 35 }, { "id": 20682504, "contributions": 1, "html_url": "https://github.com/divyarbehera", "avatar_url": "https://avatars.githubusercontent.com/u/20682504?v=4", - "login": "divyarbehera" + "login": "divyarbehera", + "lastActiveDays": 0 }, { "id": 5079169, "contributions": 1, "html_url": "https://github.com/mfsi-waseema", "avatar_url": "https://avatars.githubusercontent.com/u/5079169?v=4", - "login": "mfsi-waseema" + "login": "mfsi-waseema", + "lastActiveDays": 1 } ] diff --git a/src/app/projects/components/ProjectCard.tsx b/src/app/projects/components/ProjectCard.tsx index f2d6ba66..671e4c45 100644 --- a/src/app/projects/components/ProjectCard.tsx +++ b/src/app/projects/components/ProjectCard.tsx @@ -26,15 +26,14 @@ export default function ProjectCard({ stars, tags, }: Props) { - const [showAllTags, setShowAllTags] = useState(false); const [expandDescription, setExpandDescription] = useState(false); return ( -
+
{/* Top content section */}
-

+

{title}

{parentTitle !== "Upcoming Projects" && stars !== undefined && ( @@ -45,71 +44,46 @@ export default function ProjectCard({ )}
- {/*Description that expands on click */} + {/* Description section with fixed height */}
setExpandDescription(!expandDescription)} + onClick={() => { + if (shortDescription.length > 120) + setExpandDescription(!expandDescription); + }} + style={{ + minHeight: expandDescription ? "auto" : "4.1rem", + }} >

{shortDescription}

- {expandDescription && ( - less + + {/* Only show toggle if the content is long */} + {shortDescription.length > 120 && ( + + {expandDescription ? "less" : "more"} + )}
{parentTitle !== "Upcoming Projects" && tags && tags.length > 0 && ( -
-
- {showAllTags - ? tags.map((tag, index) => ( - - {tag} - - )) - : tags.slice(0, 2).map((tag, index) => ( - - {tag} - - ))} - {!showAllTags && tags.length > 2 && ( - - )} - {showAllTags && ( - - )} + {tag} + + ))}
)} @@ -119,9 +93,9 @@ export default function ProjectCard({ {parentTitle !== "Upcoming Projects" && (githubUrl || documentationUrl) && (githubUrl !== "NA" || documentationUrl !== "NA") && ( -
-
-
+
+
+
{githubUrl && githubUrl !== "NA" && ( (b.stars ?? 0) - (a.stars ?? 0) + ); + return (
@@ -31,7 +35,7 @@ export default function ProjectGrid({ title, projectData }: Props) {
- {projectData.map( + {sortedProjects.map( ( { title: projectTitle, diff --git a/updateProject.mjs b/updateProject.mjs index 49e0fd56..7cd3bfd2 100644 --- a/updateProject.mjs +++ b/updateProject.mjs @@ -97,6 +97,54 @@ async function getRepoData(owner, repo) { } } +// Function to get the last contribution date for a user in the organization +async function getLastContributionDate(username) { + if (!username) return null; + try { + const response = await fetch( + `https://api.github.com/users/${username}/events/public`, + { + headers: { + Authorization: `Bearer ${process.env.GITHUB_TOKEN}`, + }, + } + ); + + if (!response.ok) { + console.error(`Failed to fetch events for ${username}`); + return null; + } + + const events = await response.json(); + const orgEvents = events.filter( + (event) => event.org?.login === "mindfiredigital" + ); + + if (orgEvents.length > 0) { + const lastEvent = orgEvents[0]; + const lastActiveDate = new Date(lastEvent.created_at); + const now = new Date(); + const diffTime = Math.abs(now - lastActiveDate); + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + return diffDays; + } + + return null; + } catch (error) { + console.error(`Error fetching events for ${username}:`, error); + return null; + } +} + +// Function to get contributor data including last active days +async function getContributorData(contributor) { + const lastActiveDays = await getLastContributionDate(contributor.login); + return { + ...contributor, + lastActiveDays, + }; +} + // Main function to update projects data async function updateProjects() { const githubToken = process.env.GITHUB_TOKEN; @@ -210,18 +258,23 @@ async function updateProjects() { const repoData = await getRepoData("mindfiredigital", repoName); const contributors = await getCollaborators(repoData, githubToken); if (contributors.length > 0) { - contributorsObject[repoName] = contributors; - } else { - console.log(`No contributors found for repository: ${repoName}`); + // Get last active days for each contributor + const contributorsWithActivity = await Promise.all( + contributors.map(getContributorData) + ); + contributorsObject[repoName] = contributorsWithActivity; } } catch (error) { - console.error( - `Error processing repository ${repoName}:`, - error.message - ); + console.error(`Error processing contributors for ${repoName}:`, error); } } + // Write contributors data to file + fs.writeFileSync( + path.join(__dirname, "src/app/projects/assets/contributors.json"), + JSON.stringify(contributorsObject, null, 2) + ); + // Aggregate contributor from contributors const contributionsMap = {}; @@ -243,6 +296,7 @@ async function updateProjects() { html_url, avatar_url, login, + lastActiveDays: contributor.lastActiveDays, }; }); }