@@ -14,22 +14,20 @@ const g = new Glob(`${BASE}**/*.md`, {});
1414const delay = async ( ms ) => new Promise ( ( res ) => setTimeout ( res , ms ) ) ;
1515
1616const addArticle = async ( input ) => {
17- return fetch ( 'https://api .hashnode.com/ ' , {
17+ return fetch ( 'https://gql .hashnode.com' , {
1818 method : 'POST' ,
1919 headers : {
20- authorization : process . env . PRIVATE_HASHNODE ,
20+ authorization : 'c4c3f6be-eb75-4489-b3db-fa13257b5142' ,
2121 'Content-Type' : 'application/json'
2222 } ,
2323 body : JSON . stringify ( {
24- operationName : 'createPublication' ,
25- query : `mutation createPublication($input: CreateStoryInput!) {
26- createPublicationStory(
27- publicationId: "60242f8180da6c44eadf775b"
24+ operationName : 'publishPost' ,
25+ query : `mutation publishPost($input: PublishPostInput!) {
26+ publishPost(
2827 input: $input
2928 ) {
30- message
3129 post {
32- _id
30+ id
3331 title
3432 slug
3533 }
@@ -38,9 +36,6 @@ const addArticle = async (input) => {
3836 ` ,
3937 variables : {
4038 input : {
41- isPartOfPublication : {
42- publicationId : '60242f8180da6c44eadf775b'
43- } ,
4439 ...input
4540 }
4641 }
@@ -81,47 +76,47 @@ ${content}`;
8176 const response = await addArticle ( {
8277 title : fm . title ,
8378 subtitle : fm ?. excerpt || '' ,
79+ publicationId : '60242f8180da6c44eadf775b' ,
8480 slug : `${ TYPE } -${ fm . slug } ` ,
81+ seriesId : '65a9ad4ef60adbf4aeedd0a2' ,
8582 contentMarkdown : finalContent ,
86- coverImageURL : fm . cover ,
87- isRepublished : {
88- originalArticleURL : `https://codingcat.dev/${ TYPE } /${ fm . slug } `
83+ coverImageOptions : {
84+ coverImageURL : fm . cover
8985 } ,
86+ originalArticleURL : `https://codingcat.dev/${ TYPE } /${ fm . slug } ` ,
9087 tags : [
9188 {
92- _id : '56744722958ef13879b950d3' ,
89+ id : '56744722958ef13879b950d3' ,
9390 name : 'podcast' ,
9491 slug : 'podcast'
9592 } ,
9693 {
97- _id : '56744721958ef13879b94cad' ,
94+ id : '56744721958ef13879b94cad' ,
9895 name : 'JavaScript' ,
9996 slug : 'javascript'
10097 } ,
10198 {
102- _id : '56744722958ef13879b94f1b' ,
99+ id : '56744722958ef13879b94f1b' ,
103100 name : 'Web Development' ,
104101 slug : 'web-development'
105102 } ,
106103 {
107- _id : '56744723958ef13879b955a9' ,
104+ id : '56744723958ef13879b955a9' ,
108105 name : 'Beginner Developers' ,
109106 slug : 'beginners'
110107 }
111108 ]
112109 } ) ;
113110
114111 console . log ( 'addArticle result:' , response . status ) ;
115- if ( response ?. error ) console . error ( 'error' , response . error ) ;
116- // Get new devto url and update
112+ const json = await response . json ( ) ;
113+ if ( json ?. errors ?. length ) {
114+ console . error ( JSON . stringify ( json . errors ) ) ;
115+ continue ;
116+ }
117117 if ( response . status === 200 ) {
118- const json = await response . json ( ) ;
119- if ( json ?. errors ?. length ) {
120- console . error ( JSON . stringify ( json . errors ) ) ;
121- continue ;
122- }
123- console . log ( 'hashnode url' , json ?. data ?. createPublicationStory ?. post ?. slug ) ;
124- const hashnodeSlug = json ?. data ?. createPublicationStory ?. post ?. slug ;
118+ console . log ( 'hashnode url' , json ?. data ?. publishPost ?. post ?. slug ) ;
119+ const hashnodeSlug = json ?. data ?. publishPost ?. post ?. slug ;
125120
126121 if ( ! hashnodeSlug ) {
127122 console . error ( 'hashnode url missing' ) ;
0 commit comments