Skip to content

Commit

Permalink
filtered file
Browse files Browse the repository at this point in the history
  • Loading branch information
pandeyji711 committed Jun 1, 2024
1 parent b8242b4 commit 650bb41
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions website/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,29 @@ const apiUrl = "https://api.github.com/repos/mdazfar2/HelpOps-Hub/contents";
fetch(apiUrl)
.then((response) => response.json())
.then((data) => {
const foldersContainer = document.getElementById("folders-container");
data.forEach((item) => {
if (item.type === "dir") {
// Create a card for each folder
const folderCard = document.createElement("div");
folderCard.classList.add("folder-card");
folderCard.innerHTML = `
if (data) {
const filteredData = data.filter((file) => {
const iswebsite = file.name.toLowerCase() == "website";
return !file.name.includes(".") && !iswebsite;
});

const foldersContainer = document.getElementById("folders-container");
filteredData.forEach((item) => {
if (item.type === "dir") {
// Create a card for each folder
const folderCard = document.createElement("div");
folderCard.classList.add("folder-card");
folderCard.innerHTML = `
<h3>${item.name}</h3>
<p>${item.path}</p>
`;
// Add click event to redirect to folder
folderCard.addEventListener("click", () => {
window.location.href = item.html_url;
});
foldersContainer.appendChild(folderCard);
}
});
// Add click event to redirect to folder
folderCard.addEventListener("click", () => {
window.location.href = item.html_url;
});
foldersContainer.appendChild(folderCard);
}
});
}
})
.catch((error) => console.error("Error fetching data:", error));

0 comments on commit 650bb41

Please sign in to comment.