storyblok / storyblok-astro

Astro SDK for Storyblok CMS
158 stars 29 forks source link

How to use Relations with StoryblokComponent #870

Closed soerenmartius closed 1 month ago

soerenmartius commented 1 month ago

Hi all,

I am using Storyblok in combination with astro. One of my blocks is having a relationship to another (think BlogPost -> Author). I would like to use the StoryblokComponent to automatically rendered the registered component for Author which is a universal blok. However, the types created with the storyblok API look like this

export interface BlogPostStoryblok {
  content: string;
  author: ISbStoryData<Author> | string;
  component: "blog_post";
  _uid: string;
  [k: string]: any;
}

The <StoryblokComponent> component doesn't accept properties of type ISbSToryData though.

How can I render registered components for relations?

schabibi1 commented 1 month ago

Hi @soerenmartius From what you explained, an issue might be around how resolve_relations were configured. Could you share with us how you used resolve_relations between BlogPost and Author? It would be easier to provide you the solution if you could add more info for us.

The example of how to use resolve_relations with Astro can be found in our Ultimate Tutorial.

soerenmartius commented 1 month ago

Hi @schabibi1, thanks for getting back to me. I am not sure how this can be related to resolve_relations though (which I am using also nevertheless).

The problem I am explaining is related to the