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

30 lines
780 B
PHP
Raw Permalink Normal View History

<?php
$bodyBlocks = [];
foreach ($page->body()->toBlocks() as $block) {
if ($block->type() === 'text') {
$bodyBlocks[] = [
'type' => 'text',
'html' => $block->content()->text()->value()
];
}
}
$specificData = [
'heading' => $page->heading()->value(),
'subtitle' => $page->subtitle()->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);