Skip to content

Commit

Permalink
run hashnode env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
codercatdev committed Dec 18, 2023
1 parent fa91833 commit 128cd18
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions apps/codingcatdev/scripts/post-hashnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const addArticle = async (input) => {
return fetch('https://api.hashnode.com/', {
method: 'POST',
headers: {
authorization: '2b02d999-9e2d-409a-a2b4-7a1bcbbc58d5',
authorization: process.env.PRIVATE_HASHNODE,
'Content-Type': 'application/json'
},
body: JSON.stringify({
Expand Down Expand Up @@ -56,6 +56,7 @@ for await (const file of g) {
// TODO: We might need to add a check on cononical if this page is already in dev.to
if (
fm?.slug &&
fm.slug === 'angular-17-cypress-testing' &&
fm?.title &&
fm?.cover &&
fm?.published === 'published' &&
Expand Down Expand Up @@ -105,13 +106,20 @@ ${content}`;
console.log('addArticle result:', response.status);
if (response?.error) console.error('error', response.error);
// Get new devto url and update
if (response.status === 201) {
if (response.status === 200) {
const json = await response.json();
if (json?.url) {
console.log('Updating', file, { devto: json.url });
const hashnodeSlug = json?.data?.createPublicationStory?.post?.slug;

if (!hashnodeSlug) {
console.error('hasnode url missing');
continue;
}

if (hashnodeSlug) {
console.log('Updating', file, { hashnode: json.url });
const newMdFile = matter.stringify(content, {
...data,
devto: json.url
hashnode: hashnodeSlug
});
fs.writeFileSync(file, newMdFile, { encoding: 'utf8' });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cover: >-
https://media.codingcat.dev/image/upload/v1700112316/main-codingcatdev-photo/cypress-angular-testing.png
devto: 'https://dev.to/codingcatdev/how-to-test-angular-17-using-cypressio-27cg'
excerpt: How you can easily test Angular 17 components with Cypress
hashnode: null
hashnode:
published: published
start: 'November 11, 2023'
slug: angular-17-cypress-testing
Expand Down

1 comment on commit 128cd18

@vercel
Copy link

@vercel vercel bot commented on 128cd18 Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

codingcat-dev – ./apps/codingcatdev

codingcat-dev-git-main-coding-cat-dev.vercel.app
codingcat-dev-coding-cat-dev.vercel.app
codingcat.dev

Please sign in to comment.