Skip to content

Commit

Permalink
Sync inject-api-links with logicalclocks.github.io (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
aversey authored Nov 8, 2024
1 parent 3b8fed0 commit 63dbad8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions docs/js/inject-api-links.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
window.addEventListener("DOMContentLoaded", function () {
var windowPathNameSplits = window.location.pathname.split("/");
var majorVersionRegex = new RegExp("(\\d+[.]\\d+)")
var majorVersionRegex = new RegExp("(\\d+[.]\\d+)");
var latestRegex = new RegExp("latest");
if (majorVersionRegex.test(windowPathNameSplits[1])) { // On landing page docs.hopsworks.api/3.0 - URL contains major version
if (majorVersionRegex.test(windowPathNameSplits[1])) { // On landing page docs.hopsworks.api/4.0 - URL contains major version
// Version API dropdown
document.getElementById("hopsworks_api_link").href = "https://docs.hopsworks.ai/hopsworks-api/" + windowPathNameSplits[1] + "/generated/api/login/";
} else { // on docs.hopsworks.api/feature-store-api/3.0 / docs.hopsworks.api/hopsworks-api/3.0 / docs.hopsworks.api/machine-learning-api/3.0
document.getElementById("hsfs_javadoc_link").href = "https://docs.hopsworks.ai/hopsworks-api/" + windowPathNameSplits[1] + "/javadoc";
} else { // on / docs.hopsworks.api/hopsworks-api/4.0
if (latestRegex.test(windowPathNameSplits[2]) || latestRegex.test(windowPathNameSplits[1])) {
var majorVersion = "latest";
var majorVersion = "latest";
} else {
var apiVersion = windowPathNameSplits[2];
var majorVersion = apiVersion.match(majorVersionRegex)[0];
var apiVersion = windowPathNameSplits[2];
var majorVersion = apiVersion.match(majorVersionRegex)[0];
}
// Version main navigation
document.getElementsByClassName("md-tabs__link")[0].href = "https://docs.hopsworks.ai/" + majorVersion;
Expand All @@ -22,6 +23,6 @@ window.addEventListener("DOMContentLoaded", function () {
document.getElementsByClassName("md-tabs__link")[6].href = "https://docs.hopsworks.ai/" + majorVersion + "/admin/";
// Version API dropdown
document.getElementById("hopsworks_api_link").href = "https://docs.hopsworks.ai/hopsworks-api/" + majorVersion + "/generated/api/login/";
document.getElementById("hsfs_javadoc_link").href = "https://docs.hopsworks.ai/feature-store-api/" + majorVersion + "/javadoc";
document.getElementById("hsfs_javadoc_link").href = "https://docs.hopsworks.ai/hopsworks-api/" + majorVersion + "/javadoc";
}
});

0 comments on commit 63dbad8

Please sign in to comment.