-
Notifications
You must be signed in to change notification settings - Fork 0
/
amakuru.js
47 lines (37 loc) · 1.47 KB
/
amakuru.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
37
38
39
40
41
42
43
44
45
46
47
// sobanukirwa Articles
function sobanukirwaArticles(doc){
let postCollection = document.querySelector('.amakuru-post-wrapper');
let postDiv = document.createElement('div');
postDiv.setAttribute('class', 'post');
postDiv.setAttribute('data_id',doc.id);
let postCover = document.createElement('img');
let postDetail = document.createElement('div');
let postTitle = document.createElement('h1');
let postDesc = document.createElement('p');
let postAction = document.createElement('div');
postAction.setAttribute('class', 'post-action');
let readMore = document.createElement('button');
let share = document.createElement('button');
postCover.src = doc.data().cover;
postTitle.textContent = doc.data().title;
postDesc.textContent = doc.data().paragraphOne;
readMore.innerHTML = 'Soma byose';
share.innerHTML = doc.data().category;
postDetail.appendChild(postTitle);
postDetail.appendChild(postDesc);
postDetail.appendChild(postAction);
postAction.appendChild(readMore);
postAction.appendChild(share);
postDiv.appendChild(postCover);
postDiv.appendChild(postDetail);
postCollection.appendChild(postDiv);
let noPost = document.querySelector('.noPost');
if(postDiv==0){
noPost.textContent = "Nta nkuru zihari!";
}
}
db.collection('inkuru').where('category','==', 'Amakuru').get().then((snapshot)=> {
snapshot.docs.forEach((doc)=> {
sobanukirwaArticles(doc)
})
});