diff --git a/docs/source/_static/custom.js b/docs/source/_static/custom.js index 18b502c786e1d..be0b2a388e404 100644 --- a/docs/source/_static/custom.js +++ b/docs/source/_static/custom.js @@ -1,3 +1,4 @@ +// Add RunLLM widget document.addEventListener("DOMContentLoaded", function () { var script = document.createElement("script"); script.type = "module"; @@ -15,4 +16,23 @@ document.addEventListener("DOMContentLoaded", function () { script.async = true; document.head.appendChild(script); - }); \ No newline at end of file + }); + +// Update URL search params when tab is clicked + document.addEventListener("DOMContentLoaded", function () { + const tabs = document.querySelectorAll(".sd-tab-label"); + + function updateURL(tab) { + const syncGroup = tab.getAttribute("data-sync-group"); + const syncId = tab.getAttribute("data-sync-id"); + if (syncGroup && syncId) { + const url = new URL(window.location); + url.searchParams.set(syncGroup, syncId); + window.history.replaceState(null, "", url); + } + } + + tabs.forEach(tab => { + tab.addEventListener("click", () => updateURL(tab)); + }); +});