gatsby-starter-hero-blog icon indicating copy to clipboard operation
gatsby-starter-hero-blog copied to clipboard

Multiple categories for a post?

Open ShawonAshraf opened this issue 5 years ago • 5 comments

Currently, if I add multiple categories for a post like this, let's say


title: test author: testAuthor category: ["t1", "t2"] cover: someImage.png

I get a blank page and graphql query related error on the console. Any way around this?

ShawonAshraf avatar Jan 19 '19 21:01 ShawonAshraf

This requires a lot of changes in tens of different files. I've been trying to do this for a couple of hours now and I'm currently stuck at an error that I'm unable to debug. Did you get any further with this?

baobabKoodaa avatar Jan 29 '19 03:01 baobabKoodaa

Ok, looks like I got it now. Here is a commit in my fork: https://github.com/baobabKoodaa/blog/commit/adeebb767fd3e2da6312b69e2698695c2c45cd69

baobabKoodaa avatar Jan 29 '19 07:01 baobabKoodaa

Are you sure just changing the graphql queries won't solve this? I was tinkering with the queries, yet to reach a conclusion!

ShawonAshraf avatar Jan 31 '19 18:01 ShawonAshraf

Yes I'm sure. In addition to changing the GraphQL queries you also need to change the JS where you mangle the result of the query. We used to just get a String, now we get an array of Strings, so we need to handle it differently.

baobabKoodaa avatar Jan 31 '19 19:01 baobabKoodaa

If you still need multi category support check out my fork https://github.com/SpringSuliman/gatsby-starter-hero-blog But you need to provide category as an array for all posts I couldn't get GraphQL to accept both string and array

sulimanalruz avatar Feb 28 '19 10:02 sulimanalruz