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

22 lines
749 B
PHP
Raw Normal View History

<?php
$specificData = [
'games' => $page->children()->listed()->map(function($game) {
return [
'title' => $game->title()->value(),
'slug' => $game->slug(),
'lettering' => $game->lettering()->toFile()?->url(),
'description' => $game->description()->value(),
'thumbnail' => $game->thumbnail()->toFile()?->url(),
'backgroundImage' => $game->backgroundImage()->toFile()?->url(),
'backgroundColor' => $game->backgroundColor()->value() ?: null,
'playLink' => $game->playLinks()->value() ?: null,
];
})->values()
];
$pageData = array_merge($genericData, $specificData);
header('Content-Type: application/json');
echo json_encode($pageData);