npm gatsby 0.12.23
JS Frontmatter!

latest releases: 5.14.0-alpha-gatsby.9, 5.14.0-alpha-gatsby.6, 5.13.4...
7 years ago

@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

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!

Don't miss a new gatsby release

NewReleases is sending notifications on new releases.