All checks were successful
Deploy / Deploy to Production (push) Successful in 19s
- Router: findSlideIndex() avec fallback parent path (/blog/slug → /blog) pour sub-pages - article.json.php: réécriture — date, intro, cover, body (blocks→HTML), related articles (fallback siblings si vide) - Article.svelte: sous-composant — topbar date+retour, titre Terminal, intro, cover, body rich text (styles :global pour blocks Kirby), related articles grid, responsive - Blog.svelte: gère deux modes (liste + article) — intercepte les clics article via stopPropagation (avant le router), fetch article data, pushState pour URL, popstate pour back/forward, direct navigation /blog/slug sur mount Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
27 lines
798 B
PHP
27 lines
798 B
PHP
<?php
|
|
|
|
$related = $page->relatedArticles()->toPages();
|
|
if ($related->isEmpty()) {
|
|
$related = $page->siblings()->listed()->not($page)->shuffle()->limit(3);
|
|
}
|
|
|
|
$specificData = [
|
|
'date' => $page->date()->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);
|