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
Gridsome plugin to retrieve blog posts from your <a href = "https://hashnode.com/devblog">devblog</a> on <a href = "https://hashnode.com/">hashnode</a>. </p>
Copy file name to clipboardExpand all lines: index.js
+4-42
Original file line number
Diff line number
Diff line change
@@ -10,53 +10,16 @@ class HashnodeDevblogSource {
10
10
11
11
HASHNODE_API_URL='https://api.hashnode.com/';
12
12
13
-
asyncgetCuidsForAllPosts(){
14
-
letquery=`query{ user(username: "`+this.options.username+`") {publication {posts { cuid }}}}`;
13
+
asyncgetAllPosts(){
14
+
letquery=`query{ user(username: "`+this.options.username+`") {publication {posts { cuid slug title type dateUpdated dateAdded contentMarkdown brief coverImage tags { name }}}}}`;
15
15
let{ data }=awaitaxios.post(this.HASHNODE_API_URL,{query: query});
16
16
letpublication=data.data.user.publication;
17
17
18
18
if(!publication){
19
19
thrownewError('No publications found for this user.');
20
20
}
21
21
22
-
letposts=publication.posts;
23
-
24
-
letallCuids=[]
25
-
for(letpostofposts){
26
-
allCuids.push(post.cuid);
27
-
}
28
-
29
-
returnallCuids;
30
-
}
31
-
32
-
getQueryForSinglePostDetail(cuid){
33
-
returncuid+`:`+`post(cuid: "`+cuid+`") { slug title type dateUpdated dateAdded contentMarkdown content brief coverImage tags { name }}`;
34
-
}
35
-
36
-
asyncgetAllPostDetails(allCuids){
37
-
if(!allCuids.length){
38
-
console.warn('No posts found in the devblog.');
39
-
return[];
40
-
}
41
-
42
-
letquery=`query{`;
43
-
44
-
for(letcuidofallCuids){
45
-
query+=this.getQueryForSinglePostDetail(cuid);
46
-
}
47
-
48
-
query+='}';
49
-
50
-
let{ data }=awaitaxios.post(this.HASHNODE_API_URL,{query: query});
0 commit comments