22 lines
471 B
PHP
22 lines
471 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
$bodyBlocks = [];
|
||
|
|
foreach ($page->body()->toBlocks() as $block) {
|
||
|
|
if ($block->type() === 'text') {
|
||
|
|
$bodyBlocks[] = [
|
||
|
|
'type' => 'text',
|
||
|
|
'html' => $block->content()->text()->value(),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$specificData = [
|
||
|
|
'backgroundImage' => $page->backgroundImage()->toFile()?->url(),
|
||
|
|
'body' => $bodyBlocks,
|
||
|
|
];
|
||
|
|
|
||
|
|
$pageData = array_merge($genericData, $specificData);
|
||
|
|
|
||
|
|
header('Content-Type: application/json');
|
||
|
|
echo json_encode($pageData);
|