feat: impact-media page type with OG scraping and cache
All checks were successful
Deploy / Deploy to Production (push) Successful in 12s
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:
parent
b8352c81fa
commit
f757906584
11 changed files with 505 additions and 452 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue