From 6f8afadc71bb688ec5869c36a71ad387fbb26a2d Mon Sep 17 00:00:00 2001 From: Sergiy Dybskiy Date: Wed, 15 Oct 2025 09:36:47 -0400 Subject: [PATCH 1/2] fix(Docs) integrations without conditionals were hidden by default --- src/rehype-onboarding-lines.js | 56 +++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/src/rehype-onboarding-lines.js b/src/rehype-onboarding-lines.js index b834945cf4594..3d08252fe8c33 100644 --- a/src/rehype-onboarding-lines.js +++ b/src/rehype-onboarding-lines.js @@ -66,30 +66,58 @@ function handle_inline_options(node) { // Found "integrations: [" if (lineStr.match(/integrations:\s*\[/)) { - // Mark the opening line and hide it by default + // Mark the opening line line.properties['data-integrations-wrapper'] = 'open'; - const openClasses = Array.isArray(line.properties.className) - ? line.properties.className - : line.properties.className - ? [line.properties.className] - : []; - line.properties.className = [...openClasses, 'hidden']; // Find the closing "]," - must be exactly ], + let closeIndex = -1; for (let j = i + 1; j < node.children.length; j++) { const closeStr = toString(node.children[j]).trim(); if (closeStr === '],') { - // Mark the closing line and hide it by default + closeIndex = j; + // Mark the closing line node.children[j].properties['data-integrations-wrapper'] = 'close'; - const closeClasses = Array.isArray(node.children[j].properties.className) - ? node.children[j].properties.className - : node.children[j].properties.className - ? [node.children[j].properties.className] - : []; - node.children[j].properties.className = [...closeClasses, 'hidden']; break; } } + + // Only hide the wrapper by default if ALL content between open and close + // has data-onboarding-option (meaning it's ALL conditional) + if (closeIndex !== -1) { + let hasNonOptionContent = false; + for (let k = i + 1; k < closeIndex; k++) { + const contentLine = node.children[k]; + const isMarker = contentLine.properties['data-onboarding-option-hidden']; + const hasOption = contentLine.properties['data-onboarding-option']; + + // If this line has content and is not a marker and doesn't have an onboarding option, + // it's always-visible content + if (!isMarker && !hasOption && toString(contentLine).trim()) { + hasNonOptionContent = true; + break; + } + } + + // Only hide wrapper by default if ALL content is part of onboarding options + if (!hasNonOptionContent) { + const openClasses = Array.isArray(line.properties.className) + ? line.properties.className + : line.properties.className + ? [line.properties.className] + : []; + line.properties.className = [...openClasses, 'hidden']; + + const closeClasses = Array.isArray( + node.children[closeIndex].properties.className + ) + ? node.children[closeIndex].properties.className + : node.children[closeIndex].properties.className + ? [node.children[closeIndex].properties.className] + : []; + node.children[closeIndex].properties.className = [...closeClasses, 'hidden']; + } + } + break; // Only handle first integrations array } } From 887cec17d431c38299fb129a5d9d3f4203e6a837 Mon Sep 17 00:00:00 2001 From: Sergiy Dybskiy Date: Wed, 15 Oct 2025 09:45:40 -0400 Subject: [PATCH 2/2] simplify logic --- src/rehype-onboarding-lines.js | 63 ++++++++++++++-------------------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/src/rehype-onboarding-lines.js b/src/rehype-onboarding-lines.js index 3d08252fe8c33..58c0e27296b83 100644 --- a/src/rehype-onboarding-lines.js +++ b/src/rehype-onboarding-lines.js @@ -58,64 +58,51 @@ function handle_inline_options(node) { } }); + // Helper to add a class to a line's className property + const addClass = (line, className) => { + const existing = line.properties.className; + line.properties.className = [ + ...(Array.isArray(existing) ? existing : existing ? [existing] : []), + className, + ]; + }; + // Second pass: Mark integrations array opening/closing lines - // These should be hidden if all content inside is from options that are disabled + // Hide wrapper only if ALL content inside is conditional (from onboarding options) for (let i = 0; i < (node.children?.length ?? 0); i++) { const line = node.children[i]; const lineStr = toString(line).trim(); // Found "integrations: [" if (lineStr.match(/integrations:\s*\[/)) { - // Mark the opening line line.properties['data-integrations-wrapper'] = 'open'; - // Find the closing "]," - must be exactly ], + // Find the closing "]," let closeIndex = -1; for (let j = i + 1; j < node.children.length; j++) { - const closeStr = toString(node.children[j]).trim(); - if (closeStr === '],') { + if (toString(node.children[j]).trim() === '],') { closeIndex = j; - // Mark the closing line node.children[j].properties['data-integrations-wrapper'] = 'close'; break; } } - // Only hide the wrapper by default if ALL content between open and close - // has data-onboarding-option (meaning it's ALL conditional) - if (closeIndex !== -1) { - let hasNonOptionContent = false; - for (let k = i + 1; k < closeIndex; k++) { - const contentLine = node.children[k]; + if (closeIndex === -1) break; + + // Check if ALL content is conditional (has onboarding-option attribute or is a marker) + const hasAlwaysVisibleContent = node.children + .slice(i + 1, closeIndex) + .some(contentLine => { const isMarker = contentLine.properties['data-onboarding-option-hidden']; const hasOption = contentLine.properties['data-onboarding-option']; + const hasContent = toString(contentLine).trim(); + return hasContent && !isMarker && !hasOption; + }); - // If this line has content and is not a marker and doesn't have an onboarding option, - // it's always-visible content - if (!isMarker && !hasOption && toString(contentLine).trim()) { - hasNonOptionContent = true; - break; - } - } - - // Only hide wrapper by default if ALL content is part of onboarding options - if (!hasNonOptionContent) { - const openClasses = Array.isArray(line.properties.className) - ? line.properties.className - : line.properties.className - ? [line.properties.className] - : []; - line.properties.className = [...openClasses, 'hidden']; - - const closeClasses = Array.isArray( - node.children[closeIndex].properties.className - ) - ? node.children[closeIndex].properties.className - : node.children[closeIndex].properties.className - ? [node.children[closeIndex].properties.className] - : []; - node.children[closeIndex].properties.className = [...closeClasses, 'hidden']; - } + // Only hide wrapper if ALL content is conditional + if (!hasAlwaysVisibleContent) { + addClass(line, 'hidden'); + addClass(node.children[closeIndex], 'hidden'); } break; // Only handle first integrations array