Skip to content

Commit 0ba4b8e

Browse files
authored
Merge pull request #18 from VapiAI/fern/playground-patch
(fix): add a script to close the API playground on navigation
2 parents 6dd3acd + 55081b0 commit 0ba4b8e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

fern/assets/close-playground.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
document.addEventListener('click', function () {
2+
function isPlaygroundEndpointButtonVisible() {
3+
const playgroundEndpoint = document.querySelector('.playground-endpoint .fern-button.outlined');
4+
return playgroundEndpoint;
5+
}
6+
7+
function clickPlaygroundEndpointButton() {
8+
const playgroundEndpointButton = document.querySelector('.playground-endpoint .fern-button.outlined');
9+
if (playgroundEndpointButton) {
10+
playgroundEndpointButton.click();
11+
}
12+
}
13+
14+
const fernHeaderButtons = document.querySelectorAll('.fern-header a');
15+
fernHeaderButtons.forEach(button => {
16+
button.addEventListener('click', function () {
17+
if (isPlaygroundEndpointButtonVisible()) {
18+
clickPlaygroundEndpointButton();
19+
}
20+
});
21+
});
22+
23+
const fernHeaderTabs = document.querySelectorAll('.fern-header-container .fern-header-tab-button');
24+
fernHeaderTabs.forEach(button => {
25+
button.addEventListener('click', function () {
26+
if (isPlaygroundEndpointButtonVisible()) {
27+
clickPlaygroundEndpointButton();
28+
}
29+
});
30+
});
31+
});

fern/docs.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ landing-page:
3636
page: Welcome
3737
path: welcome.mdx
3838
css: assets/styles.css
39+
js:
40+
- path: ./assets/close-playground.js
41+
strategy: lazyOnload
3942
navbar-links:
4043
- type: minimal
4144
text: Home

0 commit comments

Comments
 (0)