-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewer.js
36 lines (33 loc) · 1.16 KB
/
viewer.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
36
document.addEventListener("DOMContentLoaded", () => {
const masonryContainer = document.getElementById("masonry");
data.forEach((item) => {
const card = document.createElement("div");
card.className = "card";
let mediaContent = "";
if (item.videoUrl) {
mediaContent = `<video src="${item.videoUrl}" controls></video>`;
} else if (item.imageUrl) {
mediaContent = `<img src="${item.imageUrl}" alt="${
item.title || "Image"
}">`;
}
card.innerHTML = `
${mediaContent}
<div class="card-content">
<h2>${item.title || "Untitled"}</h2>
<p>${item.description || ""}</p>
${
item.note
? `<p><strong>Note:</strong> ${item.note}</p>`
: ""
}
${
item.sourceUrl
? `<p><a href="${item.sourceUrl}" target="_blank">Source</a></p>`
: ""
}
</div>
`;
masonryContainer.appendChild(card);
});
});