-
Notifications
You must be signed in to change notification settings - Fork 0
/
cards.js
29 lines (29 loc) · 919 Bytes
/
cards.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
const cardcontainer = document.getElementById("card-posts");
if (localStorage.getItem("storage")) {
let cardList = [];
cardList = JSON.parse(localStorage.getItem("storage"));
if (cardList.length > 0) {
for (let i = 0; i < cardList.length; i++) {
let singleCard = ` <div class="cards">
<div class="card-img">
<img src="${cardList[i].blogImage}" alt="blog post" />
</div>
<div class="card-body">
<a href="blog.html?blog_id=${i}" class="blog-post"
>${cardList[i].blogTitle}</a
>
<p class="post">
${cardList[i].intro}
</p>
</div>
<div class="card-footer">
<a href="#"> 30<i class="fas fa-thumbs-up"></i></a>
<a href="#">60<i class="fas fa-comment"></i></a>
</div>
</div> `;
cardcontainer.insertAdjacentHTML("beforeend", singleCard);
}
}
} else {
alert("No cards to be displayed");
}