Skip to content

Commit 373dc16

Browse files
author
Dylan Shade
committed
fix(doc-selector): improve visibility handling and CSS management for index page
1 parent 1ad846e commit 373dc16

File tree

7 files changed

+62
-9
lines changed

7 files changed

+62
-9
lines changed

src/.vitepress/theme/docSelector.js

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,24 @@ if (typeof window !== "undefined") {
9898
function loadDocSelectorInBackground() {
9999
console.log("Loading DocSelector in background...");
100100

101+
// Pre-emptively add CSS to hide DocSelector on index page
102+
if (!shouldShowDocSelector()) {
103+
const style = document.createElement("style");
104+
style.id = "doc-selector-hide";
105+
style.textContent = `
106+
[data-doc-selector="true"],
107+
[data-doc-selector],
108+
.doc-selector,
109+
#doc-selector,
110+
[class*="doc-selector"],
111+
[id*="doc-selector"] {
112+
display: none !important;
113+
}
114+
`;
115+
document.head.appendChild(style);
116+
console.log("Added CSS to pre-hide DocSelector on index page");
117+
}
118+
101119
const script = document.createElement("script");
102120
script.src =
103121
"https://arweave.net/uUdfnAHLxvRswVdGTiLg4_RXYUIb_4BvyTxVQ8m1X28";
@@ -106,16 +124,30 @@ if (typeof window !== "undefined") {
106124
script.onload = () => {
107125
console.log("DocSelector loaded in background");
108126

109-
// Give component time to initialize
127+
// IMMEDIATELY hide on index page to prevent flash
128+
if (!shouldShowDocSelector()) {
129+
// Use a small delay to ensure component has rendered
130+
setTimeout(() => {
131+
hideDocSelector();
132+
console.log("DocSelector immediately hidden on index page");
133+
}, 50);
134+
}
135+
136+
// Give component time to initialize before setting ready state
110137
setTimeout(() => {
111138
componentReady = true;
112139

113-
// Apply initial visibility based on current page
140+
// Apply final visibility state based on current page
114141
if (shouldShowDocSelector()) {
142+
// Remove hide CSS if moving to non-index page
143+
const hideStyle = document.getElementById("doc-selector-hide");
144+
if (hideStyle) {
145+
hideStyle.remove();
146+
}
115147
showDocSelector();
116148
} else {
149+
// Ensure it stays hidden (redundant but safe)
117150
hideDocSelector();
118-
console.log("DocSelector preloaded and hidden on index page");
119151
}
120152
}, 200);
121153
};
@@ -144,12 +176,33 @@ if (typeof window !== "undefined") {
144176

145177
if (shouldShowDocSelector(newPath)) {
146178
if (!isDocSelectorVisible) {
179+
// Remove hide CSS when showing DocSelector
180+
const hideStyle = document.getElementById("doc-selector-hide");
181+
if (hideStyle) {
182+
hideStyle.remove();
183+
}
147184
showDocSelector();
148185
}
149186
} else {
150187
if (isDocSelectorVisible) {
151188
hideDocSelector();
152189
}
190+
// Add hide CSS when on index page
191+
if (!document.getElementById("doc-selector-hide")) {
192+
const style = document.createElement("style");
193+
style.id = "doc-selector-hide";
194+
style.textContent = `
195+
[data-doc-selector="true"],
196+
[data-doc-selector],
197+
.doc-selector,
198+
#doc-selector,
199+
[class*="doc-selector"],
200+
[id*="doc-selector"] {
201+
display: none !important;
202+
}
203+
`;
204+
document.head.appendChild(style);
205+
}
153206
}
154207
}
155208
}

src/public/ja/llms-full.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JA Technical Documentation
22

3-
Generated: 2025-06-24T19:54:31.416Z
3+
Generated: 2025-06-24T22:55:07.859Z
44

55
This file contains technical reference documentation and release notes.
66

src/public/ja/llms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JA Documentation for LLMs
22

3-
Generated: 2025-06-24T19:54:31.416Z
3+
Generated: 2025-06-24T22:55:07.859Z
44

55
This file contains structured reference documentation, release notes, and a comprehensive directory of all documentation pages.
66

src/public/llms-full.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EN Technical Documentation
22

3-
Generated: 2025-06-24T19:54:31.399Z
3+
Generated: 2025-06-24T22:55:07.826Z
44

55
This file contains technical reference documentation and release notes.
66

src/public/llms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EN Documentation for LLMs
22

3-
Generated: 2025-06-24T19:54:31.400Z
3+
Generated: 2025-06-24T22:55:07.827Z
44

55
This file contains structured reference documentation, release notes, and a comprehensive directory of all documentation pages.
66

src/public/zh/llms-full.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ZH Technical Documentation
22

3-
Generated: 2025-06-24T19:54:31.412Z
3+
Generated: 2025-06-24T22:55:07.848Z
44

55
This file contains technical reference documentation and release notes.
66

src/public/zh/llms.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ZH Documentation for LLMs
22

3-
Generated: 2025-06-24T19:54:31.412Z
3+
Generated: 2025-06-24T22:55:07.848Z
44

55
This file contains structured reference documentation, release notes, and a comprehensive directory of all documentation pages.
66

0 commit comments

Comments
 (0)