Skip to content

Commit

Permalink
fix(stringify): empty line between frontmatter and content
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Dec 11, 2024
1 parent e539b63 commit 80673e0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/frontmatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ const FRONTMATTER_DELIMITER_CODEBLOCK_STYLE = '```yaml [props]'

export function stringifyFrontMatter(data: any, content = '') {
if (!Object.keys(data).length) {
return ''
return content.trim()
}

data = flat.unflatten(data || {}, {})

return [
const frontmatter = [
FRONTMATTER_DELIMITER_DEFAULT,
stringify(data).trim(),
FRONTMATTER_DELIMITER_DEFAULT,
content,
'',
].join('\n')

if (content) {
return [frontmatter, content.trim(), ''].join('\n')
}

return frontmatter
}

export function stringifyCodeBlockProps(data: any, content = '') {
Expand Down

0 comments on commit 80673e0

Please sign in to comment.