You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have several different Contentful Content Types that are displaying on different pages of my website. On my homepage I am trying to combine them into one array and then display a few of the most recent ones. I am 90% there but the issue is I need to be able to change the slugs in this array for the different types of content.
I am able to concat them together and map over this array. Below is the code for the map.
The URL before the ${node.slug} changes, so I need to change the buttonLink dynamically based on the Contentful Content-Type.
My first thought was to display different buttons on the card component with a conditional operator, but I can't figure out anything in contentful that would be different between the different kinds of content. is there a way to query the content type name? i.e. "AllContentfulReport1" "AllcontentfulReport2".
My second thought was maybe since all of these pages are created with gatsby-node there might be a way to get the final URLs for each page after they are created, but I have no idea if that's possible.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have several different Contentful Content Types that are displaying on different pages of my website. On my homepage I am trying to combine them into one array and then display a few of the most recent ones. I am 90% there but the issue is I need to be able to change the slugs in this array for the different types of content.
I am able to concat them together and map over this array. Below is the code for the map.
The URL before the
${node.slug}
changes, so I need to change the buttonLink dynamically based on the Contentful Content-Type.My first thought was to display different buttons on the card component with a conditional operator, but I can't figure out anything in contentful that would be different between the different kinds of content. is there a way to query the content type name? i.e. "AllContentfulReport1" "AllcontentfulReport2".
My second thought was maybe since all of these pages are created with gatsby-node there might be a way to get the final URLs for each page after they are created, but I have no idea if that's possible.
Beta Was this translation helpful? Give feedback.
All reactions