2024-03-09 16:34:09 +01:00
|
|
|
<?php
|
|
|
|
|
|
2026-02-09 22:24:17 +01:00
|
|
|
|
|
|
|
|
function allYears ($article) {
|
|
|
|
|
$years = new Pages([$article->parent()]);
|
|
|
|
|
|
|
|
|
|
foreach (site()->find('textes')->children() as $year) {
|
|
|
|
|
if ($year->linkedTexts()->toPages()->has($article)) {
|
|
|
|
|
$years = $years->add($year);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $years;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-16 16:11:36 +01:00
|
|
|
function addAnchors($content) {
|
|
|
|
|
$content = preg_replace_callback('/<h3>(.*?)<\/h3>/', function($matches) {
|
|
|
|
|
$slug = Str::slug($matches[1]);
|
|
|
|
|
return '<h3 id="' . $slug . '">' . $matches[1] . '</h3>';
|
|
|
|
|
}, $content);
|
|
|
|
|
return $content;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-09 16:34:09 +01:00
|
|
|
function setTitleFontSizeClass($title, $level = 'h1')
|
|
|
|
|
{
|
|
|
|
|
$length = strlen($title);
|
|
|
|
|
|
|
|
|
|
if ($level === 'h1') {
|
|
|
|
|
switch (true) {
|
|
|
|
|
case ($length < 35):
|
|
|
|
|
return 'fs-xxl';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ($length < 70):
|
|
|
|
|
return 'fs-xl';
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return 'fs-l';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAuthorBySlug($slug)
|
|
|
|
|
{
|
2025-01-26 13:00:50 +01:00
|
|
|
$site = site();
|
|
|
|
|
$authors = page("auteurs")->children();
|
|
|
|
|
$author = $authors->find($slug);
|
2024-03-09 16:34:09 +01:00
|
|
|
|
|
|
|
|
return $author;
|
|
|
|
|
}
|
2025-02-04 17:35:09 +01:00
|
|
|
|