- Strapi Version: 4.11.1
- Operating System: Mac
- Database: None
- Node Version: 16.13.1
- NPM Version: 8.1.2
- Yarn Version:
I have a blog, and in the Strapi admin, I’ve made a number of components that will be used to create the content for each article. For example, a component with just text and a component with image and text.
I’ve created a collection type for the blog articles and added the components to the collection type as repeatable. Calling the collection type API for an article returns object arrays for each component, but there isn’t a way for the user to order them in a specific way that I’ve found.
To order them, I needed to make an instructions JSON for the layout in the collection type (just an array of strings) that is used by the frontend code to parse the data from Strapi and return article components in the right order. For example, if I want a blog article with the format of “text paragraph” + “image and text” + “text paragraph”, I need to write an array of that order so it can reorganize the data from the arrays and create the content in that order too. In that example, it will traverse the instructions array and get the first text component item and then the first image and text component item and then the second text one.
This is tedious and unintuitive. What can I do to make this functionality better and have control of the order or my repeatable components in a blog post?