fix frontmatter stringification for date fields

Switches back to custom frontmatter stringification
until support lands in preliminaries. This is necessary
because we use custom schemas for certain data types,
such as dates and times.
This commit is contained in:
Shawn Erquhart 2017-04-20 15:37:52 -04:00 committed by David Calavera
parent b64dfab42e
commit 17b40b58ea
2 changed files with 9 additions and 2 deletions

View File

@ -12,10 +12,10 @@ collections: # A list of collections the CMS should be able to edit
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
- {label: "Title", name: "title", widget: "string", tagname: "h1"}
- {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"}
- {label: "Cover Image", name: "image", widget: "image", required: false, tagname: ""}
- {label: "Body", name: "body", widget: "markdown"}
meta:
- {label: "Publish Date", name: "date", widget: "datetime", format: "YYYY-MM-DD hh:mma"}
- {label: "SEO Description", name: "description", widget: "text"}
card: {type: "image", image: "image", text: "title"}

View File

@ -1,6 +1,7 @@
import preliminaries from 'preliminaries';
import yamlParser from 'preliminaries-parser-yaml';
import tomlParser from 'preliminaries-parser-toml';
import YAML from './yaml';
// Automatically register parsers
preliminaries(true);
@ -25,7 +26,13 @@ export default class Frontmatter {
meta[key] = data[key];
}
});
// always stringify to YAML
return preliminaries.stringify(body, meta, { lang: 'yaml', delims: '---' });
const parser = {
stringify(metadata) {
return new YAML().toFile(metadata, sortedKeys);
},
};
return preliminaries.stringify(body, meta, { lang: "yaml", delims: "---", parser });
}
}