-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
58 lines (46 loc) · 2.25 KB
/
script.js
File metadata and controls
58 lines (46 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Update this string to your exact GitHub Organization/Repository name
const githubRepo = "NextStd/NextStd";
// Function to dynamically render the dev cards using GitHub API
async function renderContributors() {
const grid = document.getElementById('dev-grid');
try {
// Fetch contributor data directly from GitHub
const response = await fetch(`https://api.github.com/repos/${githubRepo}/contributors`);
if (!response.ok) {
throw new Error("Could not fetch contributors.");
}
const contributors = await response.json();
grid.innerHTML = ''; // Clear the "Loading..." text
// Filter out the GitHub Actions bot before rendering
const humanContributors = contributors.filter(dev => dev.login !== "github-actions[bot]");
humanContributors.forEach(dev => {
const card = document.createElement('div');
card.className = 'card';
// Give yourself the Lead Developer title automatically!
let role = "Open Source Contributor";
if (dev.login === "vaishnav-sg") {
role = "Lead Developer / Creator";
}
card.innerHTML = `
<img src="${dev.avatar_url}" alt="${dev.login}">
<h3>${dev.login}</h3>
<p>${role}</p>
<a href="${dev.html_url}" target="_blank" class="btn btn-secondary" style="padding: 0.4rem 1rem; font-size: 0.8rem;">GitHub Profile</a>
`;
grid.appendChild(card);
});
} catch (error) {
console.error("Error fetching GitHub contributors:", error);
// Fallback in case of API rate limits or errors
grid.innerHTML = `
<div class="card">
<img src="https://ui-avatars.com/api/?name=Vaishnav+S+G&background=88C0D0&color=2E3440" alt="Vaishnav-sg">
<h3>vaishnav-sg</h3>
<p>Lead Developer / Creator</p>
<a href="https://github.com/vaishnav-sg" target="_blank" class="btn btn-secondary" style="padding: 0.4rem 1rem; font-size: 0.8rem;">GitHub Profile</a>
</div>
`;
}
}
// Run the function when the page loads
document.addEventListener('DOMContentLoaded', renderContributors);