From a2769032ca78108e58abc45e2eb0ade8b47a6515 Mon Sep 17 00:00:00 2001 From: Harry Mellor <19981378+hmellor@users.noreply.github.com> Date: Thu, 30 Jan 2025 08:05:42 +0000 Subject: [PATCH] Set `?device={device}` when changing tab in installation guides (#12560) Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> --- docs/source/_static/custom.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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)); + }); +});