-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
35 lines (29 loc) · 1.04 KB
/
script.js
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
fetch('https://cdn.jsdelivr.net/gh/miru-project/repo@main/index.json')
.then(response => response.json())
.then(data => {
const dataContainer = document.getElementById('data-container');
renderData(data);
})
.catch(error => console.error('Error fetching data:', error));
function renderData(data) {
const dataContainer = document.getElementById('data-container');
dataContainer.innerHTML = '';
data.forEach(item => {
const card = document.createElement('div');
card.classList.add('card');
const img = document.createElement('img');
img.src = item.icon;
img.alt = `${item.name} icon`;
img.onerror = function() {
img.src = 'https://shorturl.at/nCEY1';
};
const contentDiv = document.createElement('div');
contentDiv.innerHTML = `
<h2>${item.name}</h2>
<p>Author: ${item.author}</p>
`;
card.appendChild(img);
card.appendChild(contentDiv);
dataContainer.appendChild(card);
});
}