File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ module.exports = {
2929 use: ' gridsome-source-hashnode-devblog' ,
3030 options: {
3131 username: ' ' , // Your username on hashnode
32- typeName: ' HashnodeDevblog ' // Optional
32+ typeName: ' DevblogPost ' // Optional
3333 }
3434 }
3535 ]
@@ -39,7 +39,7 @@ module.exports = {
3939## Example Query
4040```
4141query {
42- allHashnodeDevblog {
42+ allDevblogPost {
4343 edges {
4444 node {
4545 title
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ class HashnodeDevblogSource {
44 static defaultOptions ( ) {
55 return {
66 username : '' ,
7- typeName : 'HashnodeDevblog ' ,
7+ typeName : 'DevblogPost ' ,
88 }
99 }
1010
@@ -13,7 +13,13 @@ class HashnodeDevblogSource {
1313 async getCuidsForAllPosts ( ) {
1414 let query = `query{ user(username: "` + this . options . username + `") {publication {posts { cuid }}}}` ;
1515 let { data } = await axios . post ( this . HASHNODE_API_URL , { query : query } ) ;
16- let posts = await data . data . user . publication . posts ;
16+ let publication = data . data . user . publication ;
17+
18+ if ( ! publication ) {
19+ throw new Error ( 'No publications found for this user.' ) ;
20+ }
21+
22+ let posts = publication . posts ;
1723
1824 let allCuids = [ ]
1925 for ( let post of posts ) {
@@ -28,6 +34,11 @@ class HashnodeDevblogSource {
2834 }
2935
3036 async getAllPostDetails ( allCuids ) {
37+ if ( ! allCuids . length ) {
38+ console . warn ( 'No posts found in the devblog.' ) ;
39+ return [ ] ;
40+ }
41+
3142 let query = `query{` ;
3243
3344 for ( let cuid of allCuids ) {
You can’t perform that action at this time.
0 commit comments