Types for content relationship in a Slice

Hi @nf_mastroianni, a similar question came up in this thread:

Check out my reply there to see how you could possibly simplify your isBrand function into something more flexible.

You should be able to use the isFilledRelatedData() helper like this:

if(
    isFilledRelatedData(item.brand, "brand", "title") &&
    isFilledRelatedData(item.brand, "brand", "description") &&
    isFilledRelatedData(item.brand, "brand", "logo"
) {
    // ...
}

With that, you can remove the <...> code in your getByUID() call:

const page = await client
    .getByUID('page', params.uid, {
      fetchLinks: ['brand.description', 'brand.logo', 'brand.title'],
    })
    .catch(() => notFound())
2 Likes