Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit efe03b1

Browse files
committed
Add innerBlocks to formatted blocks
1 parent 5d17780 commit efe03b1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

functions/displayBlock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default function displayBlock(block, index) {
4343
case 'core/spacer':
4444
return <Blocks.BlockSpacer {...attributes} key={index} />
4545
default:
46-
return <pre key={index}>{JSON.stringify(attributes, null, 2)}</pre>
46+
return <pre key={index}>{JSON.stringify(block, null, 2)}</pre>
4747
}
4848
}
4949

functions/formatBlockData.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import getFormById from '@/api/wordpress/gravityForms/getFormById'
44
* Format and retrieve expanded block data.
55
*
66
* @author WebDevStudios
7-
* @param {Array} blocks Basic block data.
8-
* @return {Array} Formatted block data.
7+
* @param {Array} blocks Basic block data.
8+
* @return {Array} Formatted block data.
99
*/
1010
export default async function formatBlockData(blocks) {
1111
if (!blocks || !blocks.length) {
@@ -14,7 +14,7 @@ export default async function formatBlockData(blocks) {
1414

1515
return await Promise.all(
1616
blocks.map(async (block) => {
17-
const {name, attributes} = block
17+
const {name, attributes, innerBlocks} = block
1818

1919
switch (name) {
2020
case 'gravityforms/form':
@@ -23,7 +23,9 @@ export default async function formatBlockData(blocks) {
2323
break
2424
}
2525

26-
return {name, attributes}
26+
const innerBlocksFormatted = await formatBlockData(innerBlocks)
27+
28+
return {name, attributes, innerBlocks: innerBlocksFormatted}
2729
})
2830
)
2931
}

0 commit comments

Comments
 (0)