From 21efdf99b714071c3a66227463c0e192287915be Mon Sep 17 00:00:00 2001 From: isUnknown Date: Mon, 30 Mar 2026 11:15:42 +0200 Subject: [PATCH] =?UTF-8?q?fix=20:=20toc/body=20visible=20pour=20sous-arti?= =?UTF-8?q?cles,=20tri=20abonn=C3=A9s=20par=20date?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - toc plugin : remplace la vérification de profondeur fixe par parents()->findBy() pour supporter les sous-articles à n'importe quelle profondeur - newsletter : sortBy inscriptiondate (lowercase) pour correspondre au stockage Kirby Co-Authored-By: Claude Sonnet 4.6 --- site/plugins/toc/index.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/site/plugins/toc/index.php b/site/plugins/toc/index.php index e5f16fe..7d022d1 100644 --- a/site/plugins/toc/index.php +++ b/site/plugins/toc/index.php @@ -14,7 +14,7 @@ function getContent($page) { } function getTocContent($page) { - if (!$page->parent()?->parent()?->is('textes')) return null; + if (!$page->parents()->findBy('uri', 'textes')) return null; $content = (string) getContent($page); @@ -34,13 +34,13 @@ Kirby::plugin('actuel-inactuel/toc', [ preg_match_all(HEADING_PATTERN, $content, $matches, PREG_SET_ORDER); $items = []; - foreach ($matches as $m) { - $entry = ['title' => $m[3], 'slug' => Str::slug($m[3])]; + foreach ($matches as $match) { + $entry = ['title' => $match[3], 'slug' => Str::slug($match[3])]; - if ($m[1] === 'h3') { + if ($match[1] === 'h3') { $entry['children'] = []; $items[] = $entry; - } elseif ($m[1] === 'h4' && count($items) > 0) { + } elseif ($match[1] === 'h4' && count($items) > 0) { $items[count($items) - 1]['children'][] = $entry; } } @@ -50,6 +50,7 @@ Kirby::plugin('actuel-inactuel/toc', [ 'bodyWithAnchors' => function(): string { $content = getTocContent($this); + if (!$content) return ''; return preg_replace_callback(