two/0.2.0/_static/version-switcher.js
2026-10-25 10:31:27 +00:00

16 lines
576 B
JavaScript

(() => {
const versionRoot = new URL(document.documentElement.dataset.content_root, window.location.href);
const switcherUrl = new URL(DOCUMENTATION_OPTIONS.theme_switcher_json_url, versionRoot);
const resolveLinks = (root) => {
root.querySelectorAll(".version-switcher__menu a[href]").forEach((anchor) => {
anchor.href = new URL(anchor.getAttribute("href"), switcherUrl).href;
});
};
resolveLinks(document);
new MutationObserver(() => resolveLinks(document)).observe(document.documentElement, {
childList: true,
subtree: true,
});
})();