Skip to content

Commit 128cd18

Browse files
committed
run hashnode env variable
1 parent fa91833 commit 128cd18

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

  • apps/codingcatdev

‎apps/codingcatdev/scripts/post-hashnode.js‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const addArticle = async (input) => {
1717
return fetch('https://api.hashnode.com/', {
1818
method: 'POST',
1919
headers: {
20-
authorization: '2b02d999-9e2d-409a-a2b4-7a1bcbbc58d5',
20+
authorization: process.env.PRIVATE_HASHNODE,
2121
'Content-Type': 'application/json'
2222
},
2323
body: JSON.stringify({
@@ -56,6 +56,7 @@ for await (const file of g) {
5656
// TODO: We might need to add a check on cononical if this page is already in dev.to
5757
if (
5858
fm?.slug &&
59+
fm.slug === 'angular-17-cypress-testing' &&
5960
fm?.title &&
6061
fm?.cover &&
6162
fm?.published === 'published' &&
@@ -105,13 +106,20 @@ ${content}`;
105106
console.log('addArticle result:', response.status);
106107
if (response?.error) console.error('error', response.error);
107108
// Get new devto url and update
108-
if (response.status === 201) {
109+
if (response.status === 200) {
109110
const json = await response.json();
110-
if (json?.url) {
111-
console.log('Updating', file, { devto: json.url });
111+
const hashnodeSlug = json?.data?.createPublicationStory?.post?.slug;
112+
113+
if (!hashnodeSlug) {
114+
console.error('hasnode url missing');
115+
continue;
116+
}
117+
118+
if (hashnodeSlug) {
119+
console.log('Updating', file, { hashnode: json.url });
112120
const newMdFile = matter.stringify(content, {
113121
...data,
114-
devto: json.url
122+
hashnode: hashnodeSlug
115123
});
116124
fs.writeFileSync(file, newMdFile, { encoding: 'utf8' });
117125
}

‎apps/codingcatdev/src/routes/(content-single)/(non-course)/post/angular-17-cypress-testing/+page.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cover: >-
77
https://media.codingcat.dev/image/upload/v1700112316/main-codingcatdev-photo/cypress-angular-testing.png
88
devto: 'https://dev.to/codingcatdev/how-to-test-angular-17-using-cypressio-27cg'
99
excerpt: How you can easily test Angular 17 components with Cypress
10-
hashnode: null
10+
hashnode:
1111
published: published
1212
start: 'November 11, 2023'
1313
slug: angular-17-cypress-testing

0 commit comments

Comments
 (0)