Add url based title to each exhibition

This commit is contained in:
Paul Nicoué 2022-07-20 17:05:13 +02:00
parent 35351bc709
commit 2b79d762b3
2 changed files with 22 additions and 6 deletions

16
site/controllers/home.php Normal file
View file

@ -0,0 +1,16 @@
<?php
return function ($page) {
// Get exhibitions field content (stored as yaml) and parse it to return an array
$exhibitions = $page->exhibitions()->yaml();
// Add url based title to each exhibition
foreach ($exhibitions as &$exhibition) {
$exhibition['title'] = str_replace(['http://', 'https://', 'www.'], '', $exhibition['url']);
}
return [
'exhibitions' => $exhibitions
];
};