This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new ed23a1e feat(docs): maintain relative URL when switching versions
(#531)
ed23a1e is described below
commit ed23a1ead547f1c174d58cdbbda27d3367f52fab
Author: David Li <[email protected]>
AuthorDate: Tue Mar 21 15:44:51 2023 -0400
feat(docs): maintain relative URL when switching versions (#531)
Fixes #418.
---
docs/source/_static/version.js | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/docs/source/_static/version.js b/docs/source/_static/version.js
index 0f63def..51ade78 100644
--- a/docs/source/_static/version.js
+++ b/docs/source/_static/version.js
@@ -44,5 +44,25 @@ window.addEventListener("DOMContentLoaded", () => {
const li = document.createElement("li");
li.appendChild(el);
root.appendChild(li);
+
+ el.addEventListener("click", (e) => {
+ e.preventDefault();
+ try {
+ const relativePart =
window.location.pathname.replace(/^\/[^\/]+\//, "");
+ const newUrl =
`${el.getAttribute("href")}/${relativePart}`;
+ window.fetch(newUrl).then((resp) => {
+ if (resp.status === 200) {
+ window.location.href = newUrl;
+ } else {
+ window.location.href = el.getAttribute("href");
+ }
+ }, () => {
+ window.location.href = el.getAttribute("href");
+ });
+ } catch (e) {
+ window.location.href = el.getAttribute("href");
+ }
+ return false;
+ });
});
});