You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Gatsby plugin to retrieve blog posts from your <a href = "https://hashnode.com/devblog">devblog</a> on <a href = "https://hashnode.com/">hashnode</a>. </p>
letquery=`query{ user(username: "`+username+`") {publication {posts { cuid }}}}`;
6
+
asyncfunctiongetAllPosts(username){
7
+
letquery=`query{ user(username: "`+username+`") {publication {posts { cuid slug title type dateUpdated dateAdded contentMarkdown brief coverImage tags { name }}}}}`;
8
8
let{ data }=awaitaxios.post(HASHNODE_API_URL,{query: query});
9
9
letpublication=data.data.user.publication;
10
10
11
11
if(!publication){
12
12
thrownewError('No publications found for this user.');
13
13
}
14
14
15
-
letposts=publication.posts;
16
-
17
-
letallCuids=[]
18
-
for(letpostofposts){
19
-
allCuids.push(post.cuid);
20
-
}
21
-
22
-
returnallCuids;
23
-
}
24
-
25
-
functiongetQueryForSinglePostDetail(cuid){
26
-
returncuid+`:`+`post(cuid: "`+cuid+`") { cuid slug title type dateUpdated dateAdded contentMarkdown content brief coverImage tags { name }}`;
27
-
}
28
-
29
-
asyncfunctiongetAllPostDetails(allCuids){
30
-
if(!allCuids.length){
31
-
console.warn('No posts found in the devblog.');
32
-
return[];
33
-
}
34
-
35
-
letquery=`query{`;
36
-
37
-
for(letcuidofallCuids){
38
-
query+=getQueryForSinglePostDetail(cuid);
39
-
}
40
-
41
-
query+='}';
42
-
43
-
let{ data }=awaitaxios.post(HASHNODE_API_URL,{query: query});
0 commit comments