From 827309f0645f9f93f13d93eea0dcc7d06cf2fde3 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Thu, 4 Jul 2024 10:10:35 +0200 Subject: [PATCH] handling h2 in capter tabIndex --- includes/utilities.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/includes/utilities.php b/includes/utilities.php index e457ee2..b21b322 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -189,6 +189,14 @@ function build_page_chapter_index($blocks) { $chapterBlockIndex = []; foreach ($blocks as $key => $block) { + + if ($block['blockName'] == 'homegrade-content-blocks/content-heading' && isset($block['attrs']['title']) && isset($block['attrs']['headingLevel']) && $block['attrs']['headingLevel'] == "h2") { + array_push($chapterBlockIndex, [ + 'block-type' => $block['blockName'], + 'anchor' => "#" . $block['attrs']['idName'], + 'title' => $block['attrs']['title'], + ]); + } if ($block['blockName'] == 'homegrade-content-blocks/chapitrage-thematique') { foreach ($block['innerBlocks'] as $key => $innerBlock) { if (!$innerBlock['attrs']['chapterTitle']) continue;