Skip to content

Commit

Permalink
feat(roadiz): handle block prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelodelain committed Mar 26, 2024
1 parent 44506ad commit 9d26454
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/RoadizBlockFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ const isComponent = (component: string): boolean => {

const RoadizBlockFactory: FunctionalComponent<RoadizBlockFactoryProps> = ({ blocks, prefix }, context): VNodeChild => {
const blocksWithComponent = blocks.filter((block) => {
const componentName = prefix ? prefix + block.item['@type'] : block.item['@type']
const componentName = prefix
? prefix + block.item['@type'].replace(/NS([a-zA-Z]+)/g, '$1')
: block.item['@type'].replace(/NS([a-zA-Z]+)/g, '$1')

return isComponent(componentName)
})
return blocksWithComponent.map((block, index, blocks) => {
const componentName = prefix ? prefix + block.item['@type'] : block.item['@type']
const componentName = prefix
? prefix + block.item['@type'].replace(/NS([a-zA-Z]+)/g, '$1')
: block.item['@type'].replace(/NS([a-zA-Z]+)/g, '$1')

return h(resolveComponent(componentName), {
walker: block,
index,
Expand Down

0 comments on commit 9d26454

Please sign in to comment.