world-game/site/templates/about.json.php

29 lines
729 B
PHP
Raw Normal View History

<?php
$bodyBlocks = [];
foreach ($page->body()->toBlocks() as $block) {
if ($block->type() === 'text') {
$bodyBlocks[] = [
'type' => 'text',
'html' => $block->content()->text()->value()
];
}
}
$specificData = [
'intro' => $page->intro()->value(),
'body' => $bodyBlocks,
'team' => $page->files()->template('member')->sort('sort')->map(function ($file) {
return [
'name' => $file->memberName()->value(),
'role' => $file->role()->value(),
'photo' => $file->url(),
];
})->values()
];
$pageData = array_merge($genericData, $specificData);
header('Content-Type: application/json');
echo json_encode($pageData);