Skip to content

Commit 6f8afad

Browse files
committed
fix(Docs) integrations without conditionals were hidden by default
1 parent 528250c commit 6f8afad

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

src/rehype-onboarding-lines.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,58 @@ function handle_inline_options(node) {
6666

6767
// Found "integrations: ["
6868
if (lineStr.match(/integrations:\s*\[/)) {
69-
// Mark the opening line and hide it by default
69+
// Mark the opening line
7070
line.properties['data-integrations-wrapper'] = 'open';
71-
const openClasses = Array.isArray(line.properties.className)
72-
? line.properties.className
73-
: line.properties.className
74-
? [line.properties.className]
75-
: [];
76-
line.properties.className = [...openClasses, 'hidden'];
7771

7872
// Find the closing "]," - must be exactly ],
73+
let closeIndex = -1;
7974
for (let j = i + 1; j < node.children.length; j++) {
8075
const closeStr = toString(node.children[j]).trim();
8176
if (closeStr === '],') {
82-
// Mark the closing line and hide it by default
77+
closeIndex = j;
78+
// Mark the closing line
8379
node.children[j].properties['data-integrations-wrapper'] = 'close';
84-
const closeClasses = Array.isArray(node.children[j].properties.className)
85-
? node.children[j].properties.className
86-
: node.children[j].properties.className
87-
? [node.children[j].properties.className]
88-
: [];
89-
node.children[j].properties.className = [...closeClasses, 'hidden'];
9080
break;
9181
}
9282
}
83+
84+
// Only hide the wrapper by default if ALL content between open and close
85+
// has data-onboarding-option (meaning it's ALL conditional)
86+
if (closeIndex !== -1) {
87+
let hasNonOptionContent = false;
88+
for (let k = i + 1; k < closeIndex; k++) {
89+
const contentLine = node.children[k];
90+
const isMarker = contentLine.properties['data-onboarding-option-hidden'];
91+
const hasOption = contentLine.properties['data-onboarding-option'];
92+
93+
// If this line has content and is not a marker and doesn't have an onboarding option,
94+
// it's always-visible content
95+
if (!isMarker && !hasOption && toString(contentLine).trim()) {
96+
hasNonOptionContent = true;
97+
break;
98+
}
99+
}
100+
101+
// Only hide wrapper by default if ALL content is part of onboarding options
102+
if (!hasNonOptionContent) {
103+
const openClasses = Array.isArray(line.properties.className)
104+
? line.properties.className
105+
: line.properties.className
106+
? [line.properties.className]
107+
: [];
108+
line.properties.className = [...openClasses, 'hidden'];
109+
110+
const closeClasses = Array.isArray(
111+
node.children[closeIndex].properties.className
112+
)
113+
? node.children[closeIndex].properties.className
114+
: node.children[closeIndex].properties.className
115+
? [node.children[closeIndex].properties.className]
116+
: [];
117+
node.children[closeIndex].properties.className = [...closeClasses, 'hidden'];
118+
}
119+
}
120+
93121
break; // Only handle first integrations array
94122
}
95123
}

0 commit comments

Comments
 (0)