All checks were successful
Deploy / Deploy to Production (push) Successful in 18s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
766 B
PHP
28 lines
766 B
PHP
<?php
|
|
|
|
$featured = $page->featured()->toPages()->first();
|
|
|
|
$mapArticle = function($article) {
|
|
return [
|
|
'title' => $article->title()->value(),
|
|
'slug' => $article->slug(),
|
|
'published' => $article->published()->toDate('d/m/Y'),
|
|
'intro' => $article->intro()->value(),
|
|
'cover' => $article->cover()->toFile()?->url(),
|
|
];
|
|
};
|
|
|
|
$articles = $page->children()->listed()->sortBy('date', 'desc');
|
|
|
|
$specificData = [
|
|
'intro' => $page->intro()->value(),
|
|
'featured' => $featured ? $mapArticle($featured) : null,
|
|
'articles' => ($featured ? $articles->not($featured) : $articles)
|
|
->map($mapArticle)
|
|
->values(),
|
|
];
|
|
|
|
$pageData = array_merge($genericData, $specificData);
|
|
|
|
header('Content-Type: application/json');
|
|
echo json_encode($pageData);
|