From 6e5cfd629cc52716e66c645af8957c82d029f869 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Mon, 27 Nov 2023 18:49:12 +0100 Subject: [PATCH] handling chapitrage thematique in chapter index --- single-conseils.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/single-conseils.php b/single-conseils.php index 7565950..83d5735 100644 --- a/single-conseils.php +++ b/single-conseils.php @@ -5,6 +5,19 @@ if (!function_exists('build_share_urls')) { { $chapterBlockIndex = []; foreach ($blocks as $key => $block) { + if ($block['blockName'] == 'homegrade-content-blocks/chapitrage-thematique') { + foreach ($block['innerBlocks'] as $key => $innerBlock) { + if (!$innerBlock['attrs']['chapterTitle']) continue; + + $cleanedTitle = strtolower(preg_replace("/[^a-zA-Z]/", "", $innerBlock['attrs']['chapterTitle'])); + + array_push($chapterBlockIndex, [ + 'block-type' => $block['blockName'], + 'anchor' => '#' . $cleanedTitle, + 'title' => $innerBlock['attrs']['chapterTitle'], + ]); + } + } if ($block['blockName'] == 'homegrade-content-blocks/questions-container') { array_push($chapterBlockIndex, [ 'block-type' => $block['blockName'],