Skip to content

Commit a1c8cc1

Browse files
feat: add javascript to manage API explorer functionality (#568)
* chore: Add javascript to disable try it functionality in API explorer docs * chore: adding snippet for loadingexplorer properly with try it * chore: trigger CI re-run * refactor: eliminate code duplication in manage-explorers - Convert manage-explorers.js to export module function - Update LoadManageExplorers.jsx to import from script file - Removes 35 lines of duplicated logic - Improves separation of concerns (logic vs React integration) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: remove unnecessary React wrapper component - Revert manage-explorers.js to original self-executing form - Remove LoadManageExplorers.jsx (not needed) - Mintlify automatically bundles and loads JS files from the docs folder The script will now execute automatically without requiring MDX imports. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 93e6463 commit a1c8cc1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

main/scripts/manage-explorers.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
function main() {
2+
const buttonSelector = '[data-testid="try-it-button"]';
3+
const callback = function (mutationsList, observer) {
4+
if (
5+
window.location.pathname.startsWith("/docs/api") &&
6+
!window.location.pathname.startsWith("/docs/api/management/")
7+
) {
8+
const buttonToRemove = document.querySelector(buttonSelector);
9+
if (buttonToRemove) {
10+
buttonToRemove.parentNode.removeChild(buttonToRemove);
11+
}
12+
}
13+
observer.disconnect();
14+
};
15+
if ("navigation" in window) {
16+
window.navigation.addEventListener("navigate", function (event) {
17+
const destinationUrl = new URL(event.destination.url);
18+
if (
19+
destinationUrl.pathname.startsWith("/docs/api/") &&
20+
!destinationUrl.pathname.startsWith("/docs/api/management/")
21+
) {
22+
const observer = new MutationObserver(callback);
23+
observer.observe(document.body, { childList: true, subtree: true });
24+
}
25+
});
26+
}
27+
if (
28+
window.location.pathname.startsWith("/docs/api/") &&
29+
!window.location.pathname.startsWith("/docs/api/management/")
30+
) {
31+
const initialAttemptButton = document.querySelector(buttonSelector);
32+
if (initialAttemptButton) {
33+
initialAttemptButton.parentNode.removeChild(initialAttemptButton);
34+
}
35+
}
36+
}
37+
main();

0 commit comments

Comments
 (0)