I am using Gatsbyjs + Contentful for our next site. I am having an issue with our homepage slider on how to dynamically add the correct route before the slug.
For example we have product pages and blog post. and when creating a new slide in our home page slider and I have a reference to the blog post. Is there a way to add the /blog/ in the slug when contentful brings down the slug ? Is this functionality available within contentful to have routes appended to the slug?
I would approach this by adding /blog/ to the slug client side. There are lots of ways to approach doing so. Without more information like how you content is modeled or the graphql query you are using I would do something like:
let slug = item.slug;
if (item.content_type === 'blogPost') {
slug = `/blog/${slug}`;
}
If you provide some more specific information I’d be happy to give a better answer.