Closed ubionexd closed 2 years ago
This happens when you don't have an attribute within any of your post's frontmatter. In this instance you dont have thumbnail
in any.
It's still trying to look for these attributes when querying for data but it's failing as it's not in the schema it's generating from any of your markdown posts.
A quick fix is to add the frontmatter attributes it's complaining about to at least one of your posts. Thats the part at the top of your markdown before the ---
Ideally any fields like this need to be added to the schema to prevent this from happening like the one I added for the sidebar within the block starting on line 67 within gridsome.server.js
. This provides gridsome a default if its not present in any of your frontmatter like you are seeing.
Without testing this at all as I'm writing this on a phone. I would guess modifying the gridsome.server.js
file to something like this would fix this.
addSchemaResolvers({
Post: {
sidebar: {
type: 'String',
resolve(obj) {
return (obj.sidebar === undefined ? 'Default' : obj.sidebar)
}
},
thumbnail: {
type: 'String',
resolve(obj) {
return (obj.thumbnail === undefined ? null : obj.thumbnail)
}
}
}
})
I will test this and make a PR when I get a chance, the thumbnail type might need to be something other than a String
.
The thumbnail already has a check within the post template to populate it with a default if a thumbnail is not supplied (is null). Unfortunately, if it's not present in any of the frontmatter it can't query it as it won't be part of the schema. If a single entry has one it knows to set those posts without it to null. Adding this makes it part of the schema anyway and gives the thumbnail property a default value of null.
Thanks, this worked. It still crashes the developer environment if one of the markdown files is edited, but it restarts without errors.
I had the same problem with is_archived, but I removed it and it worked until now. Now I don't know what to do.