Closed philkeys closed 5 years ago
I have the same problem. I also get:
warn The gatsby-theme-events plugin has generated no Gatsby nodes. Do you need it?
Solved it! Since changing the export statement in gatsby-theme-events/gatsby-config.js
from returning an object to a function I had missed the parentheses making the function return nothing ;p
change from:
module.exports = ( { contentPath = 'data', basePath = '/' } ) => {
plugins : [
{
resolve : 'gatsby-source-filesystem',
options : {
path : contentPath
}
},
{
resolve : 'gatsby-transformer-yaml',
options : {
typeName : 'Event'
}
}
]
};
to:
module.exports = ( { contentPath = 'data', basePath = '/' } ) => ({
plugins : [
{
resolve : 'gatsby-source-filesystem',
options : {
path : contentPath
}
},
{
resolve : 'gatsby-transformer-yaml',
options : {
typeName : 'Event'
}
}
]
});
Tutorial:
https://egghead.io/lessons/gatsby-configure-a-gatsby-theme-to-take-options
https://www.gatsbyjs.org/tutorial/building-a-theme/#set-up-sitegatsby-configjs
hey all, I'm stuck and getting an error at the same spot, when I run yarn workspace site develop
:
yarn workspace gatsby-theme-events develop
I've checked my parentheses in gatsby-theme-events/gatsby-config.js
and it seems OK
gatsby-theme-events/gatsby-config.js
module.exports = ({ contentPath = 'data', basePath = '/' }) => ({
plugins: [
{
resolve: 'gatsby-source-filesystem',
options: {
path: contentPath
}
},
{
resolve: 'gatsby-transformer-yaml',
options: {
typeName: 'Event'
}
}
]
})
site/gatsby.config.js
module.exports = {
plugins: [
{
resolve: 'gatsby-theme-events',
options: {
contentPath: 'events',
basePath: '/events'
}
}
]
}
gatsby-theme-events/src/templates/event.js
import React from 'react'
import { graphql } from 'gatsby'
import Layout from '../components/layout'
import Event from '../components/event'
export const query = graphql`
query($eventID: String!) {
event(id: { eq: $eventID }) {
name
url
startDate(formatString: "MMMM D, YYYY")
endDate(formatString: "MMMM D, YYYY")
location
slug
}
}
`
const EventTemplate = ({ data: { event } }) => (
<Layout>
<Event {...event} />
</Layout>
)
export default EventTemplate
It is my first time trying out Gatsby, any help would be greatly appreciated! Cheers! :)
My Repo:
https://github.com/MoodyBones/gatsby-theme-authoring
After adding options, the theme can no longer be used directly. This isn't called out as clearly in the video as it should be.
If you use yarn workspace site develop
instead, it should work as expected with the site loading the theme, allowing you to use it with options for testing.
Hey, thanks for the tip, going forward I will just run yarn workspace site develop
The bug causing the graphql error has been solved, a silly typo in the site/gatsby.config.js
filename. It should be site/gatsby-config.js
Appreciate all the help and feedback. Bug-free and back on track. Thanks for making the course :)
Happy it helped @MoodyBones!
I'm going to close this issue, but please feel free to open new ones if you hit other snags!
Following the course posted on egghead.io all goes well until part 9.
Steps to reproduce Starting after lesson 8, setup the config and node files to accept options. At this point I start to receive the warning that the GraphQL query in the non-page component will not be run.
Note—I switched the terminology from events to categories, which you'll see in the console info I post below. That's just the naming, everything else has been the same.