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

34 lines
904 B
PHP
Raw Normal View History

<?php
$specificData = [
'intro' => [
'title' => $page->intro_title()->value(),
'text' => $page->intro_text()->value()
],
'games' => $page->children()->listed()->map(function($game) {
$badgeValue = $game->badge()->value();
$badgeLabel = 'none';
if ($badgeValue === 'new') {
$badgeLabel = 'NEW';
} elseif ($badgeValue === 'coming_soon') {
$badgeLabel = 'INCOMING';
}
return [
'title' => $game->title()->value(),
'slug' => $game->slug(),
'url' => $game->url(),
'description' => $game->description()->value(),
'cover' => $game->cover()->toFile()?->url(),
'badge' => $badgeValue,
'badge_label' => $badgeLabel,
'game_status' => $game->game_status()->value()
];
})->values()
];
$pageData = array_merge($genericData, $specificData);
header('Content-Type: application/json');
echo json_encode($pageData);