-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviewblog.js
67 lines (42 loc) · 1.54 KB
/
viewblog.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import {app,db,collection,query,where,getDocs} from "./firebase.js"
let content = document.getElementById("content");
let loader = document.getElementById("loader");
loader.style.display="flex"
content.style.display="none"
const getuserBlogs = async() =>{
const urlParam = new URLSearchParams(location.search)
const userid = urlParam.get('user')
console.log("userid",userid)
let postedBlog = document.getElementById("posted-blog")
let userview = document.getElementById("userview")
postedBlog.innerHTML = ""
const q = query(collection(db, "blogs"), where("userid", "==", userid));
const querySnapshot = await getDocs(q);
querySnapshot.forEach((doc) => {
userview.innerHTML =(
`
<img class="userimg" src="${doc.data().profile && doc.data().profile !== "undefined" ? doc.data().profile : "images/download.png"}">
<h2>${doc.data().username}</h2>
`
)
postedBlog.innerHTML += (
`
<div class="blogs">
<div class="d-flex ">
<img class="blogs-img" src="${doc.data().profile}">
<h2 class="blogs-title">${doc.data().username}</h2>
</div>
<div class="d-flex ">
<span>${doc.data().time.toDate().toDateString()}</span>
</div>
<h5>${doc.data().Title}</h5>
<hr>
<p>${doc.data().Content}</p>
</div>
`
)
loader.style.display="none"
content.style.display="block"
}
)}
getuserBlogs()