pinned invesetigations front
All checks were successful
Deploy / Deploy to Production (push) Successful in 12s

This commit is contained in:
Julie Blanc 2026-02-19 16:25:44 +01:00
parent 347c45bc22
commit f1ace8cc05
7 changed files with 338 additions and 159 deletions

View file

@ -29,15 +29,46 @@
<section class="container-cards container-cards__investigations">
<?php foreach ($page->children()->listed() as $investigation): ?>
<article class="card--article">
<?php if ($cover = $investigation->cover()->toFile()): ?>
<?php
$superPin = $page->superPinnedInvestigation()->toPage();
$pinned = $page->pinnedInvestigations()->toPages();
if ($superPin) $pinned = $pinned->not($superPin);
$shownIds = [];
$list = [];
if ($superPin) {
$list[] = ['page' => $superPin, 'type' => 'super'];
$shownIds[] = $superPin->id();
}
foreach ($pinned as $p) {
$list[] = ['page' => $p, 'type' => 'pinned'];
$shownIds[] = $p->id();
}
$rest = $page->children()->listed()->sortBy('created', 'desc')
->filter(fn($p) => !in_array($p->id(), $shownIds));
foreach ($rest as $p) {
$list[] = ['page' => $p, 'type' => 'latest'];
}
?>
<?php foreach ($list as $item):
$investigation = $item['page'];
$type = $item['type'];
$cover = $investigation->cover()->toFile();
?>
<article class="card--article<?= $type !== 'latest' ? ' pinned' : '' ?>">
<?php if ($cover): ?>
<figure>
<img src="<?= $cover->url() ?>" alt="<?= $investigation->title()->esc() ?>">
</figure>
<?php endif ?>
<?php if ($type !== 'latest'): ?>
<div class="pin"><?= svg('assets/icons/pin.svg') ?></div>
<?php endif ?>
<div class="content">
<h4 class="title"><a href="<?= $investigation->url() ?>"><?= $investigation->title()->esc() ?></a></h4>
@ -76,20 +107,20 @@
</div>
<?php endif ?>
</dl>
</div>
<?php if ($keywords = $investigation->keywords()->split()): ?>
<div class="keywords-wrapper">
<div class="keywords-wrapper">
<ul class="keywords">
<?php foreach ($keywords as $keyword): ?>
<li><a href="#keyword" target="_blank"><?= esc($keyword) ?></a></li>
<?php endforeach ?>
</ul>
</div>
<?php endif ?>
</div>
<?php endif ?>
<a class="link-block" href="<?= $investigation->url() ?>"></a>
</article>
<?php endforeach ?>