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

Commit c7f7474

Browse files
committed
Merge branch 'staging' of https://github.com/WebDevStudios/nextjs-wordpress-starter into feature/component-handling
2 parents e6ccab2 + 6f18586 commit c7f7474

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

functions/displayBlock.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
77
* @author WebDevStudios
88
* @param {object} block The block data.
99
* @param {number} index A unique key required by React.
10-
* @return {Element} A block-based component.
10+
* @return {Element} A block-based component.
1111
*/
1212
export default function displayBlock(block, index) {
1313
const {attributes, name} = block
@@ -45,7 +45,7 @@ export default function displayBlock(block, index) {
4545
case 'core/spacer':
4646
return <Blocks.BlockSpacer {...attributes} key={index} />
4747
default:
48-
return <pre key={index}>{JSON.stringify(attributes, null, 2)}</pre>
48+
return <pre key={index}>{JSON.stringify(block, null, 2)}</pre>
4949
}
5050
}
5151

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)