diff --git a/.github/workflows/rbe.yml b/.github/workflows/rbe.yml index c24ec76737..03bbe08829 100644 --- a/.github/workflows/rbe.yml +++ b/.github/workflows/rbe.yml @@ -4,6 +4,7 @@ on: [push, pull_request] env: # Update the language picker in index.hbs to link new languages. LANGUAGES: ja zh es + MDBOOK_VERSION: 0.5.1 jobs: test: @@ -27,12 +28,12 @@ jobs: - name: Install mdbook run: | mkdir bin - curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.51/mdbook-v0.4.51-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin + curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin echo "$(pwd)/bin" >> ${GITHUB_PATH} - name: Install mdbook-i18n-helpers run: | - cargo install mdbook-i18n-helpers --locked --version 0.3.4 + cargo install mdbook-i18n-helpers --locked --version 0.4.0 - name: Report versions run: | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21c4d4567b..ffc8be1fe5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,8 +56,7 @@ $ mdbook build **The following warnings can be ignored safely.** ```text -[WARN] (mdbook::preprocess::cmd): The command wasn't found, is the "gettext" preprocessor installed? -[WARN] (mdbook::preprocess::cmd): Command: mdbook-gettext + WARN The command `mdbook-gettext` for preprocessor `gettext` was not found, but is marked as optional. ``` [install Rust]: http://rust-lang.org/install.html diff --git a/README.md b/README.md index b7a7dbf879..d56a73aeba 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,7 @@ read all content offline, however! **The following warnings can be ignored safely.** ```text -[WARN] (mdbook::preprocess::cmd): The command wasn't found, is the "gettext" preprocessor installed? -[WARN] (mdbook::preprocess::cmd): Command: mdbook-gettext + WARN The command `mdbook-gettext` for preprocessor `gettext` was not found, but is marked as optional. ``` ### Using translated version diff --git a/book.toml b/book.toml index 65d8616b18..fc8ba714b1 100644 --- a/book.toml +++ b/book.toml @@ -17,7 +17,6 @@ hash-files = true additional-css = [ "theme/css/language-picker.css", ] -additional-js = ["theme/js/language-picker.js"] [rust] edition = "2021" diff --git a/theme/head.hbs b/theme/head.hbs index f9a6286907..9cbd85dfbf 100644 --- a/theme/head.hbs +++ b/theme/head.hbs @@ -1,4 +1,71 @@ diff --git a/theme/js/language-picker.js b/theme/js/language-picker.js deleted file mode 100644 index 02d8d18d9e..0000000000 --- a/theme/js/language-picker.js +++ /dev/null @@ -1,67 +0,0 @@ -(function addThemePicker() { - const rightButtonsElement = document.querySelector('.right-buttons'); - rightButtonsElement.insertAdjacentHTML("afterbegin", ` - - - `); - - const language = document.documentElement.getAttribute("lang"); - let langToggle = document.getElementById("language-toggle"); - let langList = document.getElementById("language-list"); - langToggle.addEventListener("click", (event) => { - langList.style.display = - langList.style.display == "block" ? "none" : "block"; - }); - let selectedLang = document.getElementById(language); - if (selectedLang) { - selectedLang.parentNode.classList.add("theme-selected"); - } - - // The path to the root, taking the current language into account. - let full_path_to_root = - language == "en" ? `${mdbookPathToRoot}` : `${mdbookPathToRoot}../`; - // The page path (mdbook only gives us access to the path to the Markdown file). - let path = mdbookPath.replace(/\.md$/, ".html"); - const langAnchors = Array.from(langList.querySelectorAll("a")); - for (let lang of langAnchors) { - if (lang.id == "en") { - lang.href = `${full_path_to_root}${path}`; - } else { - lang.href = `${full_path_to_root}${lang.id}/${path}`; - } - } - - // Hide languages whose target page is not available (e.g., not deployed). - // This prevents users from hitting 404s on sites that only ship some locales. - for (let lang of langAnchors) { - const url = lang.href; - // Attempt a lightweight HEAD request; fall back to hiding on failure. - fetch(url, { method: "HEAD" }).then((resp) => { - if (!resp.ok) { - const li = lang.parentNode && lang.parentNode.parentNode; - if (li) li.style.display = "none"; - } - }).catch(() => { - const li = lang.parentNode && lang.parentNode.parentNode; - if (li) li.style.display = "none"; - }); - } -})();