Skip to content

Commit

Permalink
Set ?device={device} when changing tab in installation guides (#12560)
Browse files Browse the repository at this point in the history
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
  • Loading branch information
hmellor authored Jan 30, 2025
1 parent f17f1d4 commit a276903
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion docs/source/_static/custom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Add RunLLM widget
document.addEventListener("DOMContentLoaded", function () {
var script = document.createElement("script");
script.type = "module";
Expand All @@ -15,4 +16,23 @@ document.addEventListener("DOMContentLoaded", function () {

script.async = true;
document.head.appendChild(script);
});
});

// 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));
});
});

0 comments on commit a276903

Please sign in to comment.