@alpin11/storyblok-deep-relations-resolver
TypeScript icon, indicating that this package has built-in type declarations

2.1.3 • Public • Published

Storyblok Deep Relations Resolver for React

The Storyblok Deep Relations Resolver is a React library that resolves relations on more than 2 levels in Storyblok's API responses. It enables developers to easily access nested data from the API responses, making it easier to work with complex data structures.

Installation

To install the package, run the following command:

npm install @alpin11/storyblok-deep-relations-resolver

# or with yarn

yarn add @alpin11/storyblok-deep-relations-resolver

Usage

To use the package, simply import it into your project and use the resolve function to resolve the deep relations in your Storyblok API responses.

import { resolveRelationsDeep } from '@alpin11/storyblok-deep-relations-resolver'

const storyblokApi = getStoryblokApi()

// format: <component>.<field>
export const deepRelations = [
  'articlesTeaser.articles',
  'article.author',
  'article.category',
  'primaryContactTeaser.contactPerson',
]

const { data: preResolveData } = await storyblokApi.get(`cdn/stories/${slug}`, sbParams)

const deepResolvedData = await resolveRelationsDeep(storyblokApi, preResolveData, deepRelations)

For more information on how to use the package, see the documentation.

Contributing

If you would like to contribute to the project, please follow these steps:

  • Fork the repository
  • Create a new branch for your changes
  • Make your changes and commit them with clear commit messages
  • Push your changes to your forked repository
  • Submit a pull request

License

This project is licensed under the GPLv3 License.

Reporting Bugs

If you find any bugs or issues with the package, please report them by creating a new issue on the GitHub issue tracker.

Contact

If you have any questions or feedback, feel free to contact us at our GitHub profile.

Readme

Keywords

none

Package Sidebar

Install

npm i @alpin11/storyblok-deep-relations-resolver

Weekly Downloads

152

Version

2.1.3

License

GPLv3

Unpacked Size

4.88 kB

Total Files

5

Last publish

Collaborators

  • a11devs