Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support page data declared as named exports #838

Merged
merged 1 commit into from Apr 22, 2017
Merged

Support page data declared as named exports #838

merged 1 commit into from Apr 22, 2017

Conversation

NMinhNguyen
Copy link
Contributor

@NMinhNguyen NMinhNguyen commented Apr 22, 2017

I am not entirely sure if you'd like to accept this PR, given the new GraphQL data layer, but I find it a little more pleasant to write export const data = { foo: 'bar' } instead of exports.data = { foo: 'bar' }, but that may just be me 馃槄

By the way, whilst playing around with this part of the code, I discovered that any assignment to a data MemberExpression gets picked up by load-frontmatter, even things like

const obj = {}
obj.data = {
  seriously: 'yep'
}

Saying that, I thought fixing that might be slightly out of scope for this PR..

@KyleAMathews
Copy link
Contributor

KyleAMathews commented Apr 22, 2017

Oh awesome! Yeah this totally should be supported. People naturally expect both forms of exports to be supported and there's no reason to break that expectation.

Thanks for the great PR with tests and all!

Yeah... that is an unfortunate bug. Feel free to fix it if you have a bit more time to contribute.

Also this stuff is still super applicable to 1.0 w/ GraphQL because you'll want to be able to create index pages pulling data from a mixture of JS and say Markdown pages and you'll still want to be able to export static data from your JS pages which could be picked up for the GraphQL query. At some point me or someone else will port all this Babel data extraction code over to 1.0.

@KyleAMathews KyleAMathews merged commit d1c2d41 into gatsbyjs:master Apr 22, 2017
@KyleAMathews
Copy link
Contributor

This is out in 0.12.46!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants