-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.js
More file actions
31 lines (24 loc) · 1 KB
/
github.js
File metadata and controls
31 lines (24 loc) · 1 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
const username = "kaysociety"; // <-- change this
async function loadRepos() {
const container = document.getElementById("repo-container");
try {
const response = await fetch(`https://api.github.com/users/${username}/repos`);
const repos = await response.json();
repos.slice(0, 6).forEach(repo => {
const card = document.createElement("div");
card.classList.add("repo-card");
card.innerHTML = `
<h3>${repo.name}</h3>
<p>${repo.description ? repo.description : "No description available"}</p>
<div class="repo-stats">
⭐ ${repo.stargazers_count} | 🍴 ${repo.forks_count}
</div>
<a href="${repo.html_url}" target="_blank">View on GitHub</a>
`;
container.appendChild(card);
});
} catch (error) {
container.innerHTML = "<p>Failed to load GitHub projects.</p>";
}
}
loadRepos();