world-game/site/templates/article.json.php
isUnknown 3c5b4f76dd
All checks were successful
Deploy / Deploy to Production (push) Successful in 18s
Feat: header article avec date + boutons de partage, share section bas de page, golden-grid conditionnel
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 19:19:05 +01:00

27 lines
808 B
PHP

<?php
$related = $page->relatedArticles()->toPages();
if ($related->isEmpty()) {
$related = $page->siblings()->listed()->not($page)->shuffle()->limit(3);
}
$specificData = [
'published' => $page->published()->toDate('d/m/Y'),
'intro' => $page->intro()->value(),
'cover' => $page->cover()->toFile()?->url(),
'body' => (string) $page->body()->toBlocks(),
'related' => $related->map(function($rec) {
return [
'title' => $rec->title()->value(),
'slug' => $rec->slug(),
'date' => $rec->date()->toDate('d/m/Y'),
'cover' => $rec->cover()->toFile()?->url(),
];
})->values(),
'parentUrl' => $page->parent()->url(),
];
$pageData = array_merge($genericData, $specificData);
header('Content-Type: application/json');
echo json_encode($pageData);