Skip to content

Commit

Permalink
publish: fixed basePath logic
Browse files Browse the repository at this point in the history
generated from commit 51c8cf2
  • Loading branch information
hernanpl committed Jan 22, 2025
1 parent dc5bb6e commit 7bca634
Show file tree
Hide file tree
Showing 5 changed files with 275 additions and 275 deletions.
110 changes: 55 additions & 55 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50828,10 +50828,9 @@ <h2 id="tocS_ApiArtifactoryConnectionStatusRequestDTO">ApiArtifactoryConnectionS
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// basePath = "" in dev, or "/slate" in production
const basePath = window.basePath || "";

document.addEventListener('DOMContentLoaded', () => {
// Determine basePath dynamically based on the current environment
const basePath = window.location.pathname.includes('/slate') ? '/slate' : '';
/**
* Safely joins a prefix and a path, avoiding double slashes
* e.g. joinPath("/slate","/platform/...") => "/slate/platform/..."
Expand Down Expand Up @@ -50920,66 +50919,67 @@ <h2 id="tocS_ApiArtifactoryConnectionStatusRequestDTO">ApiArtifactoryConnectionS
* Build/populate the version dropdown, fetching /platform/<PRODUCT>/versions.json
*/
function populateVersions(product, activeVersion = null) {
if (!product) return;

// Join basePath and the product-specific path
const versionsJsonPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/versions.json`
);
if (!product) return;

console.log("Fetching versions.json from:", versionsJsonPath);

fetch(versionsJsonPath)
.then((response) => response.json())
.then((versions) => {
versionOptions.innerHTML = ''; // Clear old items
const versionsJsonPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/versions.json`
);

versions.forEach((ver) => {
const li = document.createElement('li');
li.className = 'nx-dropdown__item';
li.dataset.value = ver;
li.textContent = ver;
versionOptions.appendChild(li);
fetch(versionsJsonPath)
.then(r => r.json())
.then(versions => {
versionOptions.innerHTML = '';

versions.forEach(ver => {
const li = document.createElement('li');
li.className = 'nx-dropdown__item';
li.dataset.value = ver;
li.textContent = ver;
versionOptions.appendChild(li);

// Click => redirect
li.addEventListener('click', event => {
event.stopPropagation();
versionButton.innerHTML = `
${ver}
<span class="nx-dropdown__arrow"></span>
`;
versionOptions.style.display = 'none';
versionButton.classList.remove('open');

li.addEventListener('click', (event) => {
event.stopPropagation();
// e.g. /slate/platform/<PRODUCT>/<VERSION>/index.html
const nextURL = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/${encodeURIComponent(ver)}/index.html`
);
window.location.href = nextURL;
});
});

// Decide which version to show in the button
if (activeVersion && versions.includes(activeVersion)) {
versionButton.innerHTML = `
${ver}
${activeVersion}
<span class="nx-dropdown__arrow"></span>
`;
versionOptions.style.display = 'none';
versionButton.classList.remove('open');

// Build redirect path
const redirectPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/${encodeURIComponent(ver)}/index.html`
);

console.log("Redirecting to:", redirectPath);
} else if (versions.length > 0) {
versionButton.innerHTML = `
${versions[0]}
<span class="nx-dropdown__arrow"></span>
`;
}

window.location.href = redirectPath;
});
// Remove the "current" version from the dropdown
const currentVersion = stripArrowText(versionButton.innerHTML);
if (currentVersion) {
removeSelectedVersionOption(currentVersion);
}
})
.catch(error => {
console.error(`Error populating versions for product "${product}":`, error);
});

if (activeVersion && versions.includes(activeVersion)) {
versionButton.innerHTML = `
${activeVersion}
<span class="nx-dropdown__arrow"></span>
`;
} else if (versions.length > 0) {
versionButton.innerHTML = `
${versions[0]}
<span class="nx-dropdown__arrow"></span>
`;
}
})
.catch((error) => {
console.error(`Error fetching versions for product "${product}":`, error);
});
}
}

// Toggle product dropdown
productButton.addEventListener('click', event => {
Expand Down
110 changes: 55 additions & 55 deletions platform/Lifecycle/1.177.0-01/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50828,10 +50828,9 @@ <h2 id="tocS_ApiArtifactoryConnectionStatusRequestDTO">ApiArtifactoryConnectionS
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// basePath = "" in dev, or "/slate" in production
const basePath = window.basePath || "";

document.addEventListener('DOMContentLoaded', () => {
// Determine basePath dynamically based on the current environment
const basePath = window.location.pathname.includes('/slate') ? '/slate' : '';
/**
* Safely joins a prefix and a path, avoiding double slashes
* e.g. joinPath("/slate","/platform/...") => "/slate/platform/..."
Expand Down Expand Up @@ -50920,66 +50919,67 @@ <h2 id="tocS_ApiArtifactoryConnectionStatusRequestDTO">ApiArtifactoryConnectionS
* Build/populate the version dropdown, fetching /platform/<PRODUCT>/versions.json
*/
function populateVersions(product, activeVersion = null) {
if (!product) return;

// Join basePath and the product-specific path
const versionsJsonPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/versions.json`
);
if (!product) return;

console.log("Fetching versions.json from:", versionsJsonPath);

fetch(versionsJsonPath)
.then((response) => response.json())
.then((versions) => {
versionOptions.innerHTML = ''; // Clear old items
const versionsJsonPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/versions.json`
);

versions.forEach((ver) => {
const li = document.createElement('li');
li.className = 'nx-dropdown__item';
li.dataset.value = ver;
li.textContent = ver;
versionOptions.appendChild(li);
fetch(versionsJsonPath)
.then(r => r.json())
.then(versions => {
versionOptions.innerHTML = '';

versions.forEach(ver => {
const li = document.createElement('li');
li.className = 'nx-dropdown__item';
li.dataset.value = ver;
li.textContent = ver;
versionOptions.appendChild(li);

// Click => redirect
li.addEventListener('click', event => {
event.stopPropagation();
versionButton.innerHTML = `
${ver}
<span class="nx-dropdown__arrow"></span>
`;
versionOptions.style.display = 'none';
versionButton.classList.remove('open');

li.addEventListener('click', (event) => {
event.stopPropagation();
// e.g. /slate/platform/<PRODUCT>/<VERSION>/index.html
const nextURL = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/${encodeURIComponent(ver)}/index.html`
);
window.location.href = nextURL;
});
});

// Decide which version to show in the button
if (activeVersion && versions.includes(activeVersion)) {
versionButton.innerHTML = `
${ver}
${activeVersion}
<span class="nx-dropdown__arrow"></span>
`;
versionOptions.style.display = 'none';
versionButton.classList.remove('open');

// Build redirect path
const redirectPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/${encodeURIComponent(ver)}/index.html`
);

console.log("Redirecting to:", redirectPath);
} else if (versions.length > 0) {
versionButton.innerHTML = `
${versions[0]}
<span class="nx-dropdown__arrow"></span>
`;
}

window.location.href = redirectPath;
});
// Remove the "current" version from the dropdown
const currentVersion = stripArrowText(versionButton.innerHTML);
if (currentVersion) {
removeSelectedVersionOption(currentVersion);
}
})
.catch(error => {
console.error(`Error populating versions for product "${product}":`, error);
});

if (activeVersion && versions.includes(activeVersion)) {
versionButton.innerHTML = `
${activeVersion}
<span class="nx-dropdown__arrow"></span>
`;
} else if (versions.length > 0) {
versionButton.innerHTML = `
${versions[0]}
<span class="nx-dropdown__arrow"></span>
`;
}
})
.catch((error) => {
console.error(`Error fetching versions for product "${product}":`, error);
});
}
}

// Toggle product dropdown
productButton.addEventListener('click', event => {
Expand Down
110 changes: 55 additions & 55 deletions platform/Nexus Repository/3.73.0-12/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51784,10 +51784,9 @@ <h2 id="tocS_CargoProxyRepositoryApiRequest">CargoProxyRepositoryApiRequest</h2>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// basePath = "" in dev, or "/slate" in production
const basePath = window.basePath || "";

document.addEventListener('DOMContentLoaded', () => {
// Determine basePath dynamically based on the current environment
const basePath = window.location.pathname.includes('/slate') ? '/slate' : '';
/**
* Safely joins a prefix and a path, avoiding double slashes
* e.g. joinPath("/slate","/platform/...") => "/slate/platform/..."
Expand Down Expand Up @@ -51876,66 +51875,67 @@ <h2 id="tocS_CargoProxyRepositoryApiRequest">CargoProxyRepositoryApiRequest</h2>
* Build/populate the version dropdown, fetching /platform/<PRODUCT>/versions.json
*/
function populateVersions(product, activeVersion = null) {
if (!product) return;

// Join basePath and the product-specific path
const versionsJsonPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/versions.json`
);
if (!product) return;

console.log("Fetching versions.json from:", versionsJsonPath);

fetch(versionsJsonPath)
.then((response) => response.json())
.then((versions) => {
versionOptions.innerHTML = ''; // Clear old items
const versionsJsonPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/versions.json`
);

versions.forEach((ver) => {
const li = document.createElement('li');
li.className = 'nx-dropdown__item';
li.dataset.value = ver;
li.textContent = ver;
versionOptions.appendChild(li);
fetch(versionsJsonPath)
.then(r => r.json())
.then(versions => {
versionOptions.innerHTML = '';

versions.forEach(ver => {
const li = document.createElement('li');
li.className = 'nx-dropdown__item';
li.dataset.value = ver;
li.textContent = ver;
versionOptions.appendChild(li);

// Click => redirect
li.addEventListener('click', event => {
event.stopPropagation();
versionButton.innerHTML = `
${ver}
<span class="nx-dropdown__arrow"></span>
`;
versionOptions.style.display = 'none';
versionButton.classList.remove('open');

li.addEventListener('click', (event) => {
event.stopPropagation();
// e.g. /slate/platform/<PRODUCT>/<VERSION>/index.html
const nextURL = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/${encodeURIComponent(ver)}/index.html`
);
window.location.href = nextURL;
});
});

// Decide which version to show in the button
if (activeVersion && versions.includes(activeVersion)) {
versionButton.innerHTML = `
${ver}
${activeVersion}
<span class="nx-dropdown__arrow"></span>
`;
versionOptions.style.display = 'none';
versionButton.classList.remove('open');

// Build redirect path
const redirectPath = joinPath(
basePath,
`/platform/${encodeURIComponent(product)}/${encodeURIComponent(ver)}/index.html`
);

console.log("Redirecting to:", redirectPath);
} else if (versions.length > 0) {
versionButton.innerHTML = `
${versions[0]}
<span class="nx-dropdown__arrow"></span>
`;
}

window.location.href = redirectPath;
});
// Remove the "current" version from the dropdown
const currentVersion = stripArrowText(versionButton.innerHTML);
if (currentVersion) {
removeSelectedVersionOption(currentVersion);
}
})
.catch(error => {
console.error(`Error populating versions for product "${product}":`, error);
});

if (activeVersion && versions.includes(activeVersion)) {
versionButton.innerHTML = `
${activeVersion}
<span class="nx-dropdown__arrow"></span>
`;
} else if (versions.length > 0) {
versionButton.innerHTML = `
${versions[0]}
<span class="nx-dropdown__arrow"></span>
`;
}
})
.catch((error) => {
console.error(`Error fetching versions for product "${product}":`, error);
});
}
}

// Toggle product dropdown
productButton.addEventListener('click', event => {
Expand Down
Loading

0 comments on commit 7bca634

Please sign in to comment.