From a46be6782e29dee9332a4743bc8808136f6e43cf Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 11 Oct 2025 11:13:36 -0400 Subject: Fix js file not in build --- docs/javascripts/version-selector.js | 39 ++++++++++++++++++++++++++++++++++++ docs/js/version-selector.js | 39 ------------------------------------ mkdocs.yml | 2 +- scripts/deploy-docs.sh | 10 --------- 4 files changed, 40 insertions(+), 50 deletions(-) create mode 100644 docs/javascripts/version-selector.js delete mode 100644 docs/js/version-selector.js diff --git a/docs/javascripts/version-selector.js b/docs/javascripts/version-selector.js new file mode 100644 index 0000000..fb0a187 --- /dev/null +++ b/docs/javascripts/version-selector.js @@ -0,0 +1,39 @@ +(function () { + fetch("/versions.json") + .then((r) => r.json()) + .then((data) => { + const currentPath = window.location.pathname; + const pathParts = currentPath.split("/").filter((p) => p); + const currentVersion = pathParts[0] || "latest"; + + const header = document.querySelector(".md-header__inner"); + if (!header) return; + + const select = document.createElement("select"); + select.className = "md-version-select"; + select.style.cssText = + "margin-left: 1rem; padding: 0.25rem 0.5rem; border-radius: 0.25rem; background: var(--md-default-bg-color); border: 1px solid var(--md-default-fg-color--lighter);"; + + data.versions.forEach((v) => { + const option = document.createElement("option"); + option.value = v.version; + option.textContent = v.title; + if (v.version === currentVersion) { + option.selected = true; + } + select.appendChild(option); + }); + + select.addEventListener("change", (e) => { + const newVersion = e.target.value; + const remainingPath = pathParts.slice(1).join("/"); + window.location.href = + "/" + newVersion + (remainingPath ? "/" + remainingPath : "/"); + }); + + header.appendChild(select); + }) + .catch((err) => { + console.error("Failed to load version selector:", err); + }); +})(); diff --git a/docs/js/version-selector.js b/docs/js/version-selector.js deleted file mode 100644 index fb0a187..0000000 --- a/docs/js/version-selector.js +++ /dev/null @@ -1,39 +0,0 @@ -(function () { - fetch("/versions.json") - .then((r) => r.json()) - .then((data) => { - const currentPath = window.location.pathname; - const pathParts = currentPath.split("/").filter((p) => p); - const currentVersion = pathParts[0] || "latest"; - - const header = document.querySelector(".md-header__inner"); - if (!header) return; - - const select = document.createElement("select"); - select.className = "md-version-select"; - select.style.cssText = - "margin-left: 1rem; padding: 0.25rem 0.5rem; border-radius: 0.25rem; background: var(--md-default-bg-color); border: 1px solid var(--md-default-fg-color--lighter);"; - - data.versions.forEach((v) => { - const option = document.createElement("option"); - option.value = v.version; - option.textContent = v.title; - if (v.version === currentVersion) { - option.selected = true; - } - select.appendChild(option); - }); - - select.addEventListener("change", (e) => { - const newVersion = e.target.value; - const remainingPath = pathParts.slice(1).join("/"); - window.location.href = - "/" + newVersion + (remainingPath ? "/" + remainingPath : "/"); - }); - - header.appendChild(select); - }) - .catch((err) => { - console.error("Failed to load version selector:", err); - }); -})(); diff --git a/mkdocs.yml b/mkdocs.yml index e060055..7288aef 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -43,7 +43,7 @@ markdown_extensions: permalink: true extra_javascript: - - js/version-selector.js + - javascripts/version-selector.js nav: - Home: index.md diff --git a/scripts/deploy-docs.sh b/scripts/deploy-docs.sh index 008d571..cd877cd 100755 --- a/scripts/deploy-docs.sh +++ b/scripts/deploy-docs.sh @@ -33,7 +33,6 @@ main() { fetch_existing_site build_version "$version" update_versions_manifest - copy_version_assets package_site deploy_to_pages "$version" } @@ -93,15 +92,6 @@ update_versions_manifest() { log_success "Versions manifest updated with $version_count version(s)" } -copy_version_assets() { - log_step "Copying version selector assets" - # Copy the JS file that was built into each version to the root - if [[ -f "$BUILD_DIR/latest/js/version-selector.js" ]]; then - cp "$BUILD_DIR/latest/js/version-selector.js" "$BUILD_DIR/version-selector.js" - log_success "Version selector copied to root" - fi -} - package_site() { log_step "Creating tarball" tar -C "$BUILD_DIR" -czf site.tar.gz . -- cgit v1.2.3