27 lines
844 B
PHP
27 lines
844 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
$specificData = [
|
||
|
|
'intro' => [
|
||
|
|
'title' => $page->intro_title()->value(),
|
||
|
|
'text' => $page->intro_text()->value()
|
||
|
|
],
|
||
|
|
'articles' => $page->children()->listed()->sortBy('date', 'desc')->map(function($article) {
|
||
|
|
return [
|
||
|
|
'title' => $article->title()->value(),
|
||
|
|
'slug' => $article->slug(),
|
||
|
|
'url' => $article->url(),
|
||
|
|
'date' => $article->date()->toDate('Y-m-d'),
|
||
|
|
'date_formatted' => $article->date()->toDate('d/m/Y'),
|
||
|
|
'intro' => $article->intro()->excerpt(200),
|
||
|
|
'cover' => $article->cover()->toFile()?->url(),
|
||
|
|
'author_name' => $article->author_name()->value(),
|
||
|
|
'author_photo' => $article->author_photo()->toFile()?->url()
|
||
|
|
];
|
||
|
|
})->values()
|
||
|
|
];
|
||
|
|
|
||
|
|
$pageData = array_merge($genericData, $specificData);
|
||
|
|
|
||
|
|
header('Content-Type: application/json');
|
||
|
|
echo json_encode($pageData);
|