- {(() => {
- let h2Count = 0;
- let h3Count = 0;
- let h4Count = 0;
-
- return headings.map((item, index) => {
- const sid = sanitizeStringForURL(item.id, true);
- const isAct = sid === activeId;
- const isH3Plus = item.type === "h3" || item.type === "h4";
- const isH4 = item.type === "h4";
-
- // Compute numbering
- let number = "";
- if (item.type === "h2" || item.type === "h1") {
- h2Count++;
- h3Count = 0;
- h4Count = 0;
- number = `${h2Count}.`;
- } else if (item.type === "h3") {
- h3Count++;
- h4Count = 0;
- number = `${h2Count}.${h3Count}`;
- } else if (item.type === "h4") {
- h4Count++;
- number = `${h2Count}.${h3Count}.${h4Count}`;
- }
-
- return (
-
-
-
-
- {/* Separator between items */}
- {index < headings.length - 1 && (
-
- )}
-
- );
- });
- })()}
-