fix : toc/body visible pour sous-articles, tri abonnés par date
All checks were successful
Deploy / Deploy to Production (push) Successful in 7s
All checks were successful
Deploy / Deploy to Production (push) Successful in 7s
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
5b019a8e7d
commit
21efdf99b7
1 changed files with 6 additions and 5 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue