diff --git a/fern/assets/close-playground.js b/fern/assets/close-playground.js new file mode 100644 index 000000000..7178185aa --- /dev/null +++ b/fern/assets/close-playground.js @@ -0,0 +1,31 @@ +document.addEventListener('click', function () { + function isPlaygroundEndpointButtonVisible() { + const playgroundEndpoint = document.querySelector('.playground-endpoint .fern-button.outlined'); + return playgroundEndpoint; + } + + function clickPlaygroundEndpointButton() { + const playgroundEndpointButton = document.querySelector('.playground-endpoint .fern-button.outlined'); + if (playgroundEndpointButton) { + playgroundEndpointButton.click(); + } + } + + const fernHeaderButtons = document.querySelectorAll('.fern-header a'); + fernHeaderButtons.forEach(button => { + button.addEventListener('click', function () { + if (isPlaygroundEndpointButtonVisible()) { + clickPlaygroundEndpointButton(); + } + }); + }); + + const fernHeaderTabs = document.querySelectorAll('.fern-header-container .fern-header-tab-button'); + fernHeaderTabs.forEach(button => { + button.addEventListener('click', function () { + if (isPlaygroundEndpointButtonVisible()) { + clickPlaygroundEndpointButton(); + } + }); + }); +}); diff --git a/fern/docs.yml b/fern/docs.yml index 6716bdd09..ea782a7df 100644 --- a/fern/docs.yml +++ b/fern/docs.yml @@ -36,6 +36,9 @@ landing-page: page: Welcome path: welcome.mdx css: assets/styles.css +js: + - path: ./assets/close-playground.js + strategy: lazyOnload navbar-links: - type: minimal text: Home