You've already forked comprehensive-rust
mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-07-04 05:40:29 +02:00
[DRAFT] Example
This commit is contained in:
14
.github/workflows/publish.yml
vendored
14
.github/workflows/publish.yml
vendored
@ -41,19 +41,7 @@ jobs:
|
|||||||
run: mdbook build -d book
|
run: mdbook build -d book
|
||||||
|
|
||||||
- name: Zip exercise templates
|
- name: Zip exercise templates
|
||||||
run: cd book/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/
|
run: cd book && find . -name "exerciser" -type d -exec bash -c 'zip --recurse-paths ./html/$(dirname {})/comprehensive-rust-exercises.zip {}/comprehensive-rust-exercises/' \;
|
||||||
|
|
||||||
- name: Build all translations
|
|
||||||
run: |
|
|
||||||
for po_lang in ${{ env.LANGUAGES }}; do
|
|
||||||
echo "::group::Building $po_lang translation"
|
|
||||||
MDBOOK_BOOK__LANGUAGE=$po_lang \
|
|
||||||
MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$po_lang/ \
|
|
||||||
mdbook build -d book/$po_lang
|
|
||||||
(cd book/$po_lang/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
|
|
||||||
mv book/$po_lang/html book/html/$po_lang
|
|
||||||
echo "::endgroup::"
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Setup Pages
|
- name: Setup Pages
|
||||||
uses: actions/configure-pages@v2
|
uses: actions/configure-pages@v2
|
||||||
|
11
book.toml
11
book.toml
@ -29,7 +29,7 @@ class = "bob"
|
|||||||
[output.html]
|
[output.html]
|
||||||
curly-quotes = true
|
curly-quotes = true
|
||||||
additional-js = ["speaker-notes.js"]
|
additional-js = ["speaker-notes.js"]
|
||||||
additional-css = ["svgbob.css", "speaker-notes.css", "language-picker.css"]
|
additional-css = ["svgbob.css", "speaker-notes.css"]
|
||||||
site-url = "/comprehensive-rust/"
|
site-url = "/comprehensive-rust/"
|
||||||
git-repository-url = "https://github.com/google/comprehensive-rust"
|
git-repository-url = "https://github.com/google/comprehensive-rust"
|
||||||
edit-url-template = "https://github.com/google/comprehensive-rust/edit/main/{path}"
|
edit-url-template = "https://github.com/google/comprehensive-rust/edit/main/{path}"
|
||||||
@ -82,3 +82,12 @@ line-numbers = true
|
|||||||
|
|
||||||
[output.exerciser]
|
[output.exerciser]
|
||||||
output-directory = "comprehensive-rust-exercises"
|
output-directory = "comprehensive-rust-exercises"
|
||||||
|
|
||||||
|
[output.i18n-helpers]
|
||||||
|
default_language = "en"
|
||||||
|
|
||||||
|
[output.i18n-helpers.languages]
|
||||||
|
"en" = "English"
|
||||||
|
"es" = "Spanish (Español)"
|
||||||
|
"ko" = "Korean (한국어)"
|
||||||
|
"pt-BR" = "Brazilian Portuguese (Português do Brasil)"
|
@ -1,13 +0,0 @@
|
|||||||
#language-list {
|
|
||||||
left: auto;
|
|
||||||
right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
[dir=rtl] #language-list {
|
|
||||||
left: 10px;
|
|
||||||
right: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
#language-list a {
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
@ -165,59 +165,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h1 class="menu-title">{{ book_title }}</h1>
|
<h1 class="menu-title">{{ book_title }}</h1>
|
||||||
|
|
||||||
<div class="right-buttons">
|
<div class="right-buttons">
|
||||||
<button id="language-toggle" class="icon-button" type="button"
|
<LanguagePicker>
|
||||||
title="Change language" aria-label="Change language"
|
</LanguagePicker>
|
||||||
aria-haspopup="true" aria-expanded="false"
|
|
||||||
aria-controls="language-list">
|
|
||||||
<i class="fa fa-globe"></i>
|
|
||||||
</button>
|
|
||||||
<ul id="language-list" class="theme-popup" aria-label="Languages" role="menu">
|
|
||||||
<li role="none"><button role="menuitem" class="theme">
|
|
||||||
<a id="en">English</a>
|
|
||||||
</button></li>
|
|
||||||
<li role="none"><button role="menuitem" class="theme">
|
|
||||||
<a id="pt-BR">Brazilian Portuguese (Português do Brasil)</a>
|
|
||||||
</button></li>
|
|
||||||
<li role="none"><button role="menuitem" class="theme">
|
|
||||||
<a id="ko">Korean (한국어)</a>
|
|
||||||
</button></li>
|
|
||||||
<li role="none"><button role="menuitem" class="theme">
|
|
||||||
<a id="es">Spanish (Español)</a>
|
|
||||||
</button></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
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.
|
|
||||||
{{#if (eq language "en")}}
|
|
||||||
let full_path_to_root = "{{ path_to_root }}";
|
|
||||||
{{else}}
|
|
||||||
let full_path_to_root = "{{ path_to_root }}../";
|
|
||||||
{{/if}}
|
|
||||||
// The page path (mdbook only gives us
|
|
||||||
// access to the path to the Markdown file).
|
|
||||||
let path = "{{ path }}".replace(/\.md$/, ".html");
|
|
||||||
for (let lang of langList.querySelectorAll("a")) {
|
|
||||||
if (lang.id == "en") {
|
|
||||||
lang.href = `${full_path_to_root}${path}`;
|
|
||||||
} else {
|
|
||||||
lang.href = `${full_path_to_root}${lang.id}/${path}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{{#if print_enable}}
|
{{#if print_enable}}
|
||||||
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
|
<a href="{{ path_to_root }}print.html" title="Print this book" aria-label="Print this book">
|
||||||
<i id="print-button" class="fa fa-print"></i>
|
<i id="print-button" class="fa fa-print"></i>
|
||||||
|
Reference in New Issue
Block a user