feat: impact-media page type with OG scraping and cache
All checks were successful
Deploy / Deploy to Production (push) Successful in 12s

- Add impact-media blueprint (entries field + linked investigation)
- Add minimal impact-media template
- Refactor card-open-graph snippet: accepts $url param, Kirby cache (6h TTL), decode HTML entities, empty alt on images
- Update impacts.yml to allow impact-media pages
- Render impact-media in investigation aside with dynamic count + details/summary
- Add OG cache config in config.php
- CSS formatting fixes (body, card-block-small, category)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-02-27 17:31:00 +01:00
parent b8352c81fa
commit f757906584
11 changed files with 505 additions and 452 deletions

View file

@ -0,0 +1,47 @@
<?php snippet('header') ?>
<main class="main__single">
<header class="page__header">
<p class="page__type">Impact</p>
<p class="page__category">Médiatique</p>
<h2 class="page__title"><?= $page->title()->esc() ?></h2>
</header>
<?php
$entries = $page->entries()->toEntries();
$investigation = $page->linkedInvestigation()->toPages()->first();
?>
<?php if ($entries->isNotEmpty()): ?>
<div class="page__content">
<?php foreach ($entries as $entry): ?>
<?php snippet('card-open-graph', ['url' => $entry->value()]) ?>
<?php endforeach ?>
</div>
<?php endif ?>
<?php if ($investigation): ?>
<aside class="page__aside" id="related-investigations">
<h3 class="aside__title">Enquête liée</h3>
<article class="card--article-small">
<?php if ($cover = $investigation->cover()->toFile()): ?>
<figure>
<img src="<?= $cover->url() ?>" alt="<?= $investigation->title()->esc() ?>">
</figure>
<?php endif ?>
<div class="content">
<p class="type">Enquête</p>
<h4 class="title"><a href="<?= $investigation->url() ?>"><?= $investigation->title()->esc() ?></a></h4>
</div>
<button class="btn--go-to"><a href="<?= $investigation->url() ?>"><?= svg('assets/icons/arrow-left.svg') ?></a></button>
<a class="link-block" href="<?= $investigation->url() ?>" aria-hidden="true"></a>
</article>
</aside>
<?php endif ?>
</main>
<?php snippet('bottom-bar') ?>
<?php snippet('footer') ?>

View file

@ -303,19 +303,6 @@ $dateLocale = substr(is_array($locale) ? reset($locale) : $locale, 0, 5);
</div>
<!-- <div class="card--block-small" data-impact-type="media">
<p class="category">Médiatique</p>
<div class="content">
<p>12 articles et reprises</p>
<p>1.5M de vues cumulées</p>
</div>
<details class="open-graph__details">
<summary><p class="summary-inner">Détails <span class="arrow-details"><?= svg('assets/icons/arrow-details.svg') ?></span><p></summary>
<?php snippet('card-open-graph') ?>
</details>
</div> -->
<?php
$resourcesParent = site()->find('ressources');
@ -361,6 +348,9 @@ $resources = $resourcesParent ? $resourcesParent->children()->listed()->filter(f
<?php
$impactsParent = site()->find('impacts');
$impacts = $impactsParent ? $impactsParent->children()->listed()->filter(function($impact) use ($page) {
if ($impact->intendedTemplate()->name() === 'impact-media') {
return $impact->linkedInvestigation()->toPages()->has($page);
}
return $impact->linkedInvestigations()->toPages()->has($page);
}) : null;
?>
@ -370,6 +360,23 @@ $impacts = $impactsParent ? $impactsParent->children()->listed()->filter(functio
<h3 class="aside__title"><?= t('impacts.title') ?></h3>
<?php foreach ($impacts as $impact): ?>
<?php if ($impact->intendedTemplate()->name() === 'impact-media'): ?>
<?php $entries = $impact->entries()->toEntries(); ?>
<div class="card--block-small" data-impact-type="media">
<p class="type">Médiatique</p>
<div class="content">
<p><?= $entries->count() ?> article<?= $entries->count() > 1 ? 's' : '' ?> et reprise<?= $entries->count() > 1 ? 's' : '' ?></p>
</div>
<?php if ($entries->isNotEmpty()): ?>
<details class="open-graph__details">
<summary><p class="summary-inner">Détails <span class="arrow-details"><?= svg('assets/icons/arrow-details.svg') ?></span></p></summary>
<?php foreach ($entries as $entry): ?>
<?php snippet('card-open-graph', ['url' => $entry->value()]) ?>
<?php endforeach ?>
</details>
<?php endif ?>
</div>
<?php else: ?>
<div class="card--block-small has-link">
<div class="group-top">
<p class="type"><?= t('impact.type') ?></p>
@ -394,6 +401,7 @@ $impacts = $impactsParent ? $impactsParent->children()->listed()->filter(functio
<a class="link-block" href="<?= $impact->url() ?>" aria-hidden="true"></a>
</div>
<?php endif ?>
<?php endforeach ?>
</aside>