fix persist with missing body from file
This commit is contained in:
parent
495e7c8743
commit
0183ad433b
@ -102,4 +102,21 @@ describe('Frontmatter', () => {
|
|||||||
].join('\n')
|
].join('\n')
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should stringify YAML with missing body', () => {
|
||||||
|
expect(
|
||||||
|
FrontmatterFormatter.toFile({ tags: ['front matter', 'yaml'], title: 'YAML' })
|
||||||
|
).toEqual(
|
||||||
|
[
|
||||||
|
'---',
|
||||||
|
'tags:',
|
||||||
|
' - front matter',
|
||||||
|
' - yaml',
|
||||||
|
'title: YAML',
|
||||||
|
'---',
|
||||||
|
'',
|
||||||
|
'',
|
||||||
|
].join('\n')
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -50,7 +50,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
toFile(data, sortedKeys) {
|
toFile(data, sortedKeys) {
|
||||||
const { body, ...meta } = data;
|
const { body = '', ...meta } = data;
|
||||||
|
|
||||||
// always stringify to YAML
|
// always stringify to YAML
|
||||||
// `sortedKeys` is not recognized by gray-matter, so it gets passed through to the parser
|
// `sortedKeys` is not recognized by gray-matter, so it gets passed through to the parser
|
||||||
|
Loading…
x
Reference in New Issue
Block a user