Skip to content

Commit f0ca851

Browse files
committed
Added Directory Fetching Logic through Github API
1 parent dec9e4a commit f0ca851

File tree

7 files changed

+1030
-0
lines changed

7 files changed

+1030
-0
lines changed

Website/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ <h1>Machine Learning Repos</h1>
2525
<h2>Welcome to the Machine Learning Repositories</h2>
2626
<p>This website provides an overview of various machine learning repositories available on GitHub, brought to you by the RecodeHive organization.</p>
2727
<a href="https://github.com/recodehive/machine-learning-repos" class="cta-button">Visit the Repository</a>
28+
</section>.
29+
<section id="repo-list">
30+
<h2>Repositories</h2>
31+
<ul id="directories">
32+
</ul>
2833
</section>
2934
</main>
3035

Website/js/script.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
document.addEventListener('DOMContentLoaded', function() {
2+
const directoriesList = document.getElementById('directories');
3+
4+
async function fetchDirectories() {
5+
try {
6+
const response = await fetch('/api/github/repos');
7+
8+
if (!response.ok) {
9+
throw new Error(`HTTP error! status: ${response.status}`);
10+
}
11+
12+
const data = await response.json();
13+
14+
const directories = data.filter(item => item.type === 'dir' && item.name !== 'Website');
15+
16+
directories.forEach(directory => {
17+
const li = document.createElement('li');
18+
li.classList.add('card');
19+
20+
const h3 = document.createElement('h3');
21+
h3.textContent = directory.name;
22+
23+
const a = document.createElement('a');
24+
a.href = directory.html_url;
25+
a.textContent = 'View Repository';
26+
a.classList.add('btn-view-repo');
27+
28+
li.appendChild(h3);
29+
li.appendChild(a);
30+
directoriesList.appendChild(li);
31+
});
32+
} catch (error) {
33+
console.error('Error fetching directories:', error);
34+
directoriesList.innerHTML = '<li class="card">Failed to load directories.</li>';
35+
}
36+
}
37+
38+
fetchDirectories();
39+
});

Website/server/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
GITHUB_TOKEN = YOUR GITHUB TOKEN

0 commit comments

Comments
 (0)