Metadata are not parsed when content does not exist
pkonieczniak opened this issue · comments
Przemysław Konieczniak commented
Input:
const path = join(tmpdir(), 'markdown.md')
const content = '---\ntitle: fake title\nauthor: fooBar\n---'
fs.writeFileSync(path, content)
const source = fs.readFileSync(path, 'utf8')
const result = markdownParser(source)
console.log(result)
Result:
{
metadata: {},
content: '---\ntitle: fake title\nauthor: fooBar\n---'
}
Works fine when content is defined.
Input:
const path = join(tmpdir(), 'markdown.md')
const content = '---\ntitle: fake title\nauthor: fooBar\n---\nContent goes here'
fs.writeFileSync(path, content)
const source = fs.readFileSync(path, 'utf8')
const result = markdownParser(source)
console.log(result)
Result:
{
metadata: { title: 'fake Title', author: 'fooBar' },
content: 'Content goes here'
}
Alberto Terragni commented
I've released version 2.0.1 which covers also this use case.