#Empty block as place holder for UI

8 messages · Page 1 of 1 (latest)

digital walrus
#

Hi. I have page collection where entire page is dynamic generated using the data and layout from payload. i been using empty block as place holder in the front i loop through and check the blocktype and place the appropriate component.

I'm is there a better way to do this?

woven zodiacBOT
digital walrus
#

This is my logic for handling this:

export const PlaceHolderForUi = (label: string) => ({
    slug: label.toLocaleLowerCase().replaceAll(' ', '_'),
    labels: {
      singular: label,
      plural: label,
    },
    fields:[
        {
            name: "title",
            label: `This block will added ${label} component in UI`,
            type: "group",
            fields:[],
        }
    ]
})

Let me if there is better way to do it.

blissful shoal
#

iirc blocks are not required to have fields, you can pass an empty array

#

But I don't see anything wrong with your approach

digital walrus
blissful shoal
#

probably not

#

If you need the flexibility of blocks, this is fine