@jbolda fixed the 2nd issue ever filed for Gatsby! Supporting "frontmatter" in javascript files. This should still be considered experimental but you can now export an object from your JS pages and that data will be available in your templates, other pages, etc.
I added a quick example of how this works on the starter blog
- http://gatsbyjs.github.io/gatsby-starter-blog/2016-12-9-react-component-post/
- gatsbyjs/gatsby-starter-blog@e333cb1
Note that this initial release is still fairly limited at the moment. This only works in js/jsx files and you must export your data using commonjs (e.g. exports.data = {}
). Also we only parse data layer one level deep so
this works:
exports.data = {
title: "My sweet title",
}
this still does not work:
exports.data = {
title: "My sweet title",
goingDeeper: {
word: "to your mother",
}
}
PRs welcome to make this work on es6 exports (export const data
) as well as for subobjects!