feat: render full map content (image, intro, markers) in PagedJS

- Fix template check 'carte' → 'map' so map subpages are served by API
- Add parseMarker() and enrich parseCarte() with static image, intro, markers
- Include map children in parseGeoformat() alongside chapters
- Resolve map block references in chapters to full carte data
- Update narrative store flattening with new carte fields
- Replace MapBlock placeholder with full carte rendering (title, image, tags, intro, markers with icons and blocks)
- Add default marker-pin.svg for markers without custom icon

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-02-26 15:00:28 +01:00
parent 9d80845335
commit 41fbe71a1f
5 changed files with 171 additions and 22 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" fill="currentColor"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5a2.5 2.5 0 1 1 0-5 2.5 2.5 0 0 1 0 5z"/></svg>

After

Width:  |  Height:  |  Size: 236 B

View file

@ -106,9 +106,14 @@ function parseBlocks($blocksField, $page) {
break;
case 'map':
$blockData['content'] = [
'map' => $block->map()->value()
];
$mapPage = $block->map()->toPages()->first();
if ($mapPage) {
$blockData['content'] = parseCarte($mapPage);
} else {
$blockData['content'] = [
'map' => $block->map()->value()
];
}
break;
default:
@ -135,18 +140,40 @@ function parseChapter($chapter) {
];
}
/**
* Parse un marqueur
*/
function parseMarker($marker) {
return [
'title' => $marker->title()->value(),
'cover' => resolveFileUrl($marker->cover(), $marker),
'icon' => $marker->markerIcon()->toFile() ? $marker->markerIcon()->toFile()->url() : null,
'iconSize' => $marker->markerIconSize()->value() ?? 40,
'blocks' => parseBlocks($marker->text(), $marker)
];
}
/**
* Parse une carte
*/
function parseCarte($carte) {
$markers = [];
foreach ($carte->children()->listed() as $child) {
if ($child->intendedTemplate()->name() === 'marker') {
$markers[] = parseMarker($child);
}
}
$staticImage = $carte->file('map-static.png');
return [
'id' => $carte->id(),
'uuid' => $carte->uuid()->toString(),
'id' => $carte->id(),
'uuid' => $carte->uuid()->toString(),
'template' => 'carte',
'title' => $carte->title()->value(),
'slug' => $carte->slug(),
'tags' => $carte->tags()->isNotEmpty() ? $carte->tags()->split() : [],
'text' => resolveImagesInHtml($carte->text()->value(), $carte)
'title' => $carte->title()->value(),
'slug' => $carte->slug(),
'tags' => $carte->tags()->isNotEmpty() ? $carte->tags()->split() : [],
'image' => $staticImage ? $staticImage->url() : null,
'intro' => resolveImagesInHtml($carte->text()->value(), $carte),
'markers' => $markers
];
}
@ -154,10 +181,13 @@ function parseCarte($carte) {
* Parse un geoformat
*/
function parseGeoformat($geoformat) {
$chapters = [];
$children = [];
foreach ($geoformat->children()->listed() as $child) {
if ($child->intendedTemplate()->name() === 'chapter') {
$chapters[] = parseChapter($child);
$template = $child->intendedTemplate()->name();
if ($template === 'chapter') {
$children[] = parseChapter($child);
} elseif ($template === 'map') {
$children[] = parseCarte($child);
}
}
@ -171,7 +201,7 @@ function parseGeoformat($geoformat) {
'tags' => $geoformat->tags()->isNotEmpty() ? $geoformat->tags()->split() : [],
'cover' => resolveFileUrl($geoformat->cover(), $geoformat),
'text' => resolveImagesInHtml($geoformat->text()->value(), $geoformat),
'children' => $chapters
'children' => $children
];
}
@ -197,7 +227,7 @@ foreach ($page->children()->listed() as $child) {
if ($template === 'geoformat') {
$data['children'][] = parseGeoformat($child);
} elseif ($template === 'carte') {
} elseif ($template === 'map') {
$data['children'][] = parseCarte($child);
}
}