Skip to content

Commit 51dc2b7

Browse files
committed
fix: simplify workflow
1 parent 58f46a1 commit 51dc2b7

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

.github/workflows/publish-article.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,20 @@ jobs:
3636
fs.mkdirSync(folder, { recursive: true });
3737
const filePath = path.join(folder, `${article.slug}.mdx`);
3838
39-
// build front-matter
40-
const fm = [
41-
'---',
42-
`title: "${article.title.replace(/"/g,'\\"')}"`,
43-
`description: "${article.meta_description.replace(/"/g,'\\"')}"`,
44-
`image: ${article.image_url}`,
45-
`author: Dillion Verma`,
46-
`tag: ${article.tags && article.tags.length ? article.tags[0] : ''}`,
47-
`publishedOn: ${article.created_at}`,
48-
`featured: true`,
49-
'---\n'
50-
].join('\n');
39+
// build front-matter using YAML.stringify for safer escaping
40+
const yaml = require('js-yaml');
41+
42+
const frontMatter = {
43+
title: article.title,
44+
description: article.meta_description,
45+
image: article.image_url,
46+
author: "Dillion Verma",
47+
tags: article.tags || [],
48+
publishedOn: article.created_at,
49+
featured: true
50+
};
51+
52+
const fm = '---\n' + yaml.dump(frontMatter) + '---\n';
5153
5254
// write file with front-matter + markdown content
5355
fs.writeFileSync(filePath, fm + article.content_markdown);

0 commit comments

Comments
 (0)