Support writing frontmatter in multiple formats (#933)
* Format JSON files. Currently we store JSON as a single line in files. We should prettify it like we do the other formats. * Add output parsers to the frontmatter list. * Cleanup frontmatter format parser options. * Support writing frontmatter in TOML and JSON. Right now we can read TOML or JSON frontmatter by inferring, but we can only write frontmatter in YAML. This change allows the frontmatter format to be explicitly set for reading and writing. * Fix frontmatter formatter. * Update Frontmatter formatter tests. * Update frontmatter format docs.
This commit is contained in:
@ -173,7 +173,7 @@ class Backend {
|
||||
return (entry) => {
|
||||
const format = resolveFormat(collectionOrEntity, entry);
|
||||
if (entry && entry.raw !== undefined) {
|
||||
const data = (format && attempt(format.fromFile.bind(null, entry.raw))) || {};
|
||||
const data = (format && attempt(format.fromFile.bind(format, entry.raw))) || {};
|
||||
if (isError(data)) console.error(data);
|
||||
return Object.assign(entry, { data: isError(data) ? {} : data });
|
||||
}
|
||||
|
Reference in New Issue
Block a user